Friday 26 April 2019

Java ClassPath Issues

When you specify -jar then the -cp parameter will be ignored.
When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.
You also cannot "include" needed jar files into another jar file (you would need to extract their contents and put the .class files into your jar file)
You have two options:
  1. include all jar files from the lib directory into the manifest (you can use relative paths there)
  2. Specify everything (including your jar) on the commandline using -cp
    java -cp MyJar.jar:lib/* com.somepackage.subpackage.Main

No comments:

Post a Comment

Please comment here