Hello:
I am trying to compile a very simple Java J2SE program that will connect to a Postgres database. I am using:
* an Apple computer running Mac OS/X 10.4
* Postgres 8.0
* JDBC driver postgresql-8.0-311.jdbc3.jar
The JDBC jar file IS in the CLASSPATH environment variable. The code of the program is the following:
public static void main (String[] args) {
try {
Class.forName ("org.postgresql.Driver");
} catch (ClassNotFoundException e) {
System.out.println (e.getMessage ());
e.printStackTrace ();
}
The program compiles fine but the error message I get when I run the program is the following:
[Session started at 2005-06-24 23:32:14 -0500.]
org.postgresql.Driver
java.lang.ClassNotFoundException: org.postgresql.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:199)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at gastos.main(gastos.java:17)
I have tried placing the JDBC jar file at different directories while adjusting the CLASSPATH variable but I keep getting the same annoying error. I also tried the -cp flag when invoking 'java' to execute the program, but it does not work. I ran out of ideas and the exercise is becoming very frustrating. Any suggestions will be highly appreciated. Thanks a lot in advance.
Regards,
Enrique