Joel
Joel

Reputation: 3454

postgresql classpath under windows

I'm running this under windows vista cmd prompt:

java -classpath C:\postgresql-8.4-701.jdbc4.jar -jar myJar.jar

I get the error:

Cannot load postgresql driver. org.postgresql.Driver

The line causing the error is:

Class.forName("org.postgresql.Driver");

But in eclipse, the program works, and the postgresql library is referenced under the "Referenced Libraries".

How to fix this please ? I need to run the program under the windows cmd prompt while getting the same result I get in Eclipse IDE.

Upvotes: 1

Views: 1858

Answers (1)

Kal
Kal

Reputation: 24910

I think this has to do with the fact that since you are using an executable jar, the classpath variable is being ignored.

You should make sure that your myJar.jar has the correct classpath entries in its manifest file using

Class-Path: postgres...jar

Make sure that its in the same directory as myJar.jar

Upvotes: 1

Related Questions