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

# 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#
 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.