title: Loading the postgreSQL JDBC driver
body: <p>I am trying to load a JDBC postgreSQL driver for a Java program. I know this is all over the Internet. I have tried many solutions, but none of them have worked for me.</p>
  
  <p>The problem is that I get this error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError:    
  classes/com/freire/test/JDBCExample/class
  Caused by: java.lang.ClassNotFoundException: classes.com.freire.test.JDBCExample.class
  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:306)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
  </code></pre>
  
  <p>And my code looks like this:</p>
  
  <pre><code>package com.freire.test;
  import java.sql.DriverManager;
  import java.sql.Connection;
  import java.sql.SQLException;
  
  public class JDBCExample 
  {
      public static void main(String[] argv) 
      {
          System.out.println("JDBC Connection Testing");
          try {
              Class.forName("org.postgresql.Driver");
          } catch (ClassNotFoundException e) {
              System.out.println("PostgreSQL JDBC Driver not included!");
          }
      }
  }
  </code></pre>
  
  <p>And the structure of my project looks like this:</p>
  
  <pre><code>myProject
   src
     com
       freire
         test
           JDBCExample.java
   classes
     com
       freire
         test
           JDBCExample.class
   lib
     postgresql-9.2-1003.jdbc3.jar
  </code></pre>
  
  <p>Compiling works fine:</p>
  
  <pre><code>java -d classes/ src/com/freire/test/JDBCExample.java
  </code></pre>
  
  <p>But executing produces the error:</p>
  
  <pre><code>java classes/com/freire/test/JDBCExample
  </code></pre>
  
  <p>Worth to say that I am working on a OS X Mountain Lion.</p>
  
  <p>Any help will be appreciated.</p>