Home Adding jar files in each jvm run dont seem to work
Reply: 1

Adding jar files in each jvm run dont seem to work

vonhact
1#
vonhact Published in 2017-12-07 10:01:46Z

I hava a java program which requires me to add an additional jar file when I run it.

What I first do is:

$ javac -classpath postgresql-42.1.4.jar myFile.java

It executes with no errors. But when I then try to do:

$ java -classpath postgresql-42.1.4.jar myFile

It says:

Error: Could not find or load main class myFile

The current folder im in looks like this:

postgresql-42.1.4.jar myFile.class myFile.java

There are no errors in myFile.java file (it is setup correctly).

Kayaman
2#
Kayaman Reply to 2017-12-07 10:15:33Z

You've overridden the classpath, so it only contains the driver. You need to include your current directory there as well.

java -cp postgresql-42.1.4.jar:. myFile

Also please adhere to Java naming conventions. It should be MyFile, not myFile.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.325203 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO