Re: executable jars and libraries
Mark Space wrote:
I never said Sun wasn't correct -- for large system. But for small and
desktop systems, their method is a large pain. This should of [sic] been
something settable in a global JVM configuration somewhere, in my
opinion. And the default should have been to allow packaging Jars and
using the CLASSPATH environment variable.
That *is* the default, along with allowing the "-cp" option to the "java"
command. You override that default with the "-jar" option.
Aren't you glad?
The latter is cheesy, and I hate environment variable space pollution,
but sometimes you need a quick way to test a new install too.
It's not a big deal. You make a zip or tarball containing your JAR and the
needed dependencies. You put the dependency JARs in a subdirectory, say lib/
or ./, relative to the application JAR. The user or administrator unpacks the
zip or tarball into the directory of their choice. The manifest for your JAR,
as mentioned upthread, has a 'Class-Path:' entry that lists the dependency
JARs in their relative location. Bob's your uncle.
<http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html>
The notion that CLASSPATH or local class path options should be the default
for the "-jar" option is blatantly incorrect. It's already the default for
the non-"-jar" way, so you don't need it for the "-jar" way. The whole
*point* of the "-jar" option is to make the JAR file more or less
self-contained and immune to the vagaries of multiple deployment environments.
Combining that with "-cp" or the envar would defeat that purpose.
--
Lew