I have my classes with the main method in main.jar, and an external
library in external.jar.
Now, I can start my application with:
java -cp main.jar:external.jar MainClass
Fine, but the following command does *not* work:
java -cp external.jar -jar main.jar MainClass
It doesn't find the classes in external.jar. Why not??
Thanks!
Markus
hinduu@gmail.com - 28 Sep 2005 06:24 GMT
Hi Markus
Here is the statement about -jar option in the java docs
-jar Executes a program encapsulated in a JAR archive. The
first argument is the name of a JAR file instead of a
startup class name.
In order for this option to work, the manifest of the
JAR file must contain a line of the form Main-
Class:classname. Here, classname identifies the class
having the public static void main(String[] args)
method that serves as your application's starting
point. See the Jar tool reference page and the Jar
trail of the Java Tutorial for information about work-
ing with Jar files and Jar-file manifests. When you
use this option, the JAR file is the source of all
user classes, and other user class path settings are
ignored.
The last sentence explains your scenario
-H
> I have my classes with the main method in main.jar, and an external
> library in external.jar.
[quoted text clipped - 9 lines]
> Thanks!
> Markus
Roedy Green - 28 Sep 2005 06:28 GMT
>It doesn't find the classes in external.jar. Why not??
If you use a jar the classpath has to go INSIDE The jar. See
http://mindprod.com/jgloss/jar.html
The alternative is to put your aux jars in the ext directory.
See http://mindprod.com/jgloss/classpath.html

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.