title: NoClassDefFoundError: StudentRegistrar
body: <p>I'm getting errors in my code and I've been banging my head against this for a few hours.  Any thoughts.... There are two java files in this Application and a DB.properties file.  Right now the program isn't supposed to do anything other than test the connection to the database.  If I missed something, please forgive me as I am new to Java.</p>
  
  <p><strong>StudentRegistrar.java</strong></p>
  
  <pre><code>package studentregistrar;
  
  
  import java.io.File;
  import java.sql.Connection;
  import java.sql.ResultSet;
  import java.sql.Statement;
  public class StudentRegistrar {
  
  /**
   * @param args the command line arguments
   */
  public static void main(String[] args) throws Exception
  {
  
  
      // TODO code application logic here
      System.out.println(args);
      System.out.println(args.length);
      if (args.length == 0)
      {
          System.out.println("Usage: java -classpath driver_class_path" 
                  + File.pathSeparator 
                  + ".  Test DB.properties");
          return;
      }
      else
          SimpleDataSource.init(args[0]);
  
      Connection conn = SimpleDataSource.getConnection();
      try
      {
          Statement stat = conn.createStatement();
  
          stat.execute("CREATE TABLE Test (Name CHAR(20))");
          stat.execute("INSERT INTO Text VALUES ('Romeo')");
  
          ResultSet result = stat.executeQuery("Select * FROM Test");
          result.next();
          stat.execute("DROP TABLE Test");
      }
      finally
      {
          conn.close();
      }
  }
  }
  </code></pre>
  
  <p><strong>SimpleDataSource.java</strong></p>
  
  <pre><code>package studentregistrar;
  
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.sql.Connection;
  import java.sql.DriverManager;
  import java.sql.SQLException;
  import java.util.Properties;
  
  
  public class SimpleDataSource {
  
  public static void init(String filename)
          throws IOException, ClassNotFoundException
  {
      Properties props = new Properties();
      FileInputStream in = new FileInputStream(filename);
      props.load(in);
      String driver = "com.mysql.jdbc.Driver";
      url = props.getProperty("jdbc.url");
      username = props.getProperty("jdbc.username");
      if (username == null) username = "";
      password = props.getProperty("jdbc.password");
      if (password == null) password = "";
      if(driver != null)
          Class.forName(driver);
  } 
  
  public static Connection getConnection()
          throws SQLException
  {
      return DriverManager.getConnection(url, username, password);
  }
  
  private static String url;
  private static String username;
  private static String password;
  
  }
  </code></pre>
  
  <p><strong>DB.properties</strong></p>
  
  <pre><code>jdbc.url=jdbc:mysql://localhost:3306/registrar
  jdbc.username=root
  jdbc.password=notmypassword
  jdbc.driver=com.mysql.jdbc.Driver
  </code></pre>
  
  <p>I compile the application in NetBeans and from what I can tell I run the command</p>
  
  <pre><code> java -class driver_class_path:. StudentRegistrar DB.properties
  </code></pre>
  
  <p>And I get the Following errors:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: StudentRegistrar
  Caused by: java.lang.ClassNotFoundException: StudentRegistrar
  at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
  Could not find the main class: StudentRegistrar.  Program will exit.
  </code></pre>
  
  <p>What Am I Doing WRONG!!!  I'm sure it's something stupid.</p>
  
  <p>Thanks for your time.
  Kevsteelio</p>