It there a utility that will trace dependencies to provide a list of
all the classes that need to be included to create a free-standing
jar?
It is embarrassing to give folks a jar missing classes. The app works
fine on your machine where the classes are available on the classpath.
Obviously it can't find dynamically loaded stuff, but usually you know
about that, and can use Jet to find those.

Signature
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm
Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
Bjorn Borud - 17 Jun 2005 00:57 GMT
[Roedy Green <look-on@mindprod.com.invalid>]
| It is embarrassing to give folks a jar missing classes. The app
| works fine on your machine where the classes are available on the
| classpath.
don't set the classpath -- don't assume anything about the
environment. include everything in the application jar. write a
manifest that identifies the main class. if it becomes 20Mb big it is
still smaller than the average web browser and you don't usually hear
anyone complaining about their disk footprint. (often it won't even
be that big.)
this means that if Java is installed all the user has to do to run the
application is
java -jar app.jar
(modulo any options you'd need to pass along to the JVM anyway)
no fiddling around.
-Bjørn
John Currier - 17 Jun 2005 01:14 GMT
How about setting your classpath to nothing and try to run the code.
But you said this "a free-standing jar". Do you mean one that you run
with java -jar? If so then your classpath settings shouldn't come into
the picture at all...and you wouldn't be asking this question.
Assuming, of course, that you haven't inappropriately put any
jars/classes into your JRE.
John
Bjorn Borud - 17 Jun 2005 01:04 GMT
["John Currier" <md4curvs@gmail.com>]
| How about setting your classpath to nothing and try to run the code.
the classpath environment variable should always be set to nothing.
-Bjørn
John Currier - 17 Jun 2005 02:01 GMT
I agree, but doesn't his question imply otherwise?
I definitely don't agree with you on bundling everything in one massive
jar. I guess you've never written anything that runs against a generic
database. My SchemaSpy (a runnable jar) would be MANY megabytes (vs.
88KB) if I tried to include every database driver I could think of into
my jar. I'm not sure how you would expect someone to handle the
various versions of drivers that exist for any given database vendor.
John
http://schemaspy.sourceforge.net
Bjorn Borud - 17 Jun 2005 14:25 GMT
["John Currier" <md4curvs@gmail.com>]
| I agree, but doesn't his question imply otherwise?
|
[quoted text clipped - 4 lines]
| my jar. I'm not sure how you would expect someone to handle the
| various versions of drivers that exist for any given database vendor.
I am talking about self-contained applications where the dependencies
are known up front. in this scenario a few megabytes of bytecode
matters significantly less than people needing to ask "what jar
provides..." N times before they get it to run.
-Bjørn
Mark Rose - 17 Jun 2005 01:48 GMT
> It there a utility that will trace dependencies to provide a list of
> all the classes that need to be included to create a free-standing
> jar?
You can use GenJar (http://genjar.sourceforge.net). It packages only the
dependencies from starting point(s) you specify, like your main method.
You can specify exceptions which have to be included etc.
It hasn't been updated for a long time now and has some outstanding
issues which should only affect exotic needs. It does its job very well
otherwise.
Mark.
Roedy Green - 17 Jun 2005 05:24 GMT
>It is embarrassing to give folks a jar missing classes. The app works
>fine on your machine where the classes are available on the classpath.
there are two issues. One is testing. That can be done by temporarily
setting the classpath to empty.
The other is figuring out what to put in the jar, rather than finding
out one class at a time per test, or per JET compile.

Signature
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm
Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
Rogan Dawes - 23 Jun 2005 08:43 GMT
>>It is embarrassing to give folks a jar missing classes. The app works
>>fine on your machine where the classes are available on the classpath.
[quoted text clipped - 4 lines]
> The other is figuring out what to put in the jar, rather than finding
> out one class at a time per test, or per JET compile.
Try proguard: http://proguard.sourceforge.net
It has other features as well (optimising, obfuscating), but it can be
used as a pure "dependency follower".
I use it to generate a complete self-contained jar for WebScarab, by
sucking in only the classes required from the various jars I depend on.
Regards,
Rogan

Signature
Rogan Dawes
*ALL* messages to discard@dawes.za.net will be dropped, and added
to my blacklist. Please respond to "nntp AT dawes DOT za DOT net"