main.jarand you issue the command:
lib1.jar
lib2.jar
c:\tmp\> java -cp lib1.jar;lib2.jar -jar main.jarRight?
Wrong! All you get is the dreaded java.lang.NoClassDefFound
exception. As I recently found out (much to my chagrin: I'm supposed to be a veteran Java developer) the -jar option is mutually exclusive of -classpath.
Why did Sun made it this way? Why java.exe does not complain and provide help in that case? Beats me. How you work this around? You have to specify the classpath in your MANIFEST.MF file packaged with your jar.
So to make the jar work in the previous example:
java -jar main.jarand, in your MANIFEST.MF:
Class-Path: lib1.jar lib2.jar
Nessun commento:
Posta un commento