
Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
> "java -jar jarfile.jar arguments...."
> As I understand the definition of the manifest and class path behavior,
> if there is no "Class-Path:" parameter in the manifest the class path
> should default to the class path given by -classpath or, if that's
> absent, to $CLASSPATH. What have I misunderstood?
That the external class path is ignored when you invoke "java -jar".
> -jar
> Execute a program encapsulated in a JAR file.
...
> When you use this option, the JAR file is the source of all user classes,
> and other user class path settings are ignored.
<http://java.sun.com/javase/6/docs/technotes/tools/solaris/java.html>
Use the manifest. Distribute the JARs with the app.

Signature
Lew
Martin Gregorie - 01 Nov 2007 19:24 GMT
> That the external class path is ignored when you invoke "java -jar".
Thanks. I was reading the "jar' manual in the SDK Documentation tree and
found its description of Class-Path: somewhat woolly. In particular it
does NOT say that the external class path is ignored!
> Use the manifest. Distribute the JARs with the app.
I thought it might come to that. OK, next reality check:
All the relevant jar files came in RPMs or zip files. I unpacked them in
the same directory (/home/java symlinked as /usr/java) so they are
grouped with their documentation, etc. as separate trees. I'd like to
leave them that way for ease of maintenance, but when it comes to
distributing my jar file and simplifying its manifest it would be better
to have them all in the same directory. What about the following:
- make a directory to receive the jar file collection
- build the application jar file with a manifest saying that the
support jar files are in the same directory
- putting the application jar file in directory
- populate the directory with symlinks to the supporting jar files
I think that should work. Is there any obvious flaw? This way the
manifest file is installation-independent and distribution is easy: just
distribute a zip archive of that directory.

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
Lew - 01 Nov 2007 20:30 GMT
> I was reading the "jar' manual in the SDK Documentation tree and
> found its description of Class-Path: somewhat woolly. In particular it
> does NOT say that the external class path is ignored!
That's because it's not a feature of the "jar" command, it's a feature of the
"java" command.
You will note that the link I provided is for the "java" command.

Signature
Lew
Martin Gregorie - 02 Nov 2007 00:19 GMT
>> I was reading the "jar' manual in the SDK Documentation tree and found
>> its description of Class-Path: somewhat woolly. In particular it does
[quoted text clipped - 4 lines]
>
> You will note that the link I provided is for the "java" command.
I hadn't - but have now found it. Thanks.

Signature
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
...
> "java -jar jarfile.jar arguments...."
java -cp jarfile.jar com.the.MainClass arguments....

Signature
Andrew Thompson
http://www.athompson.info/andrew/