using java -verbose option to jar only files being loaded by the interpreter

L

lbrtchx

say you have an application that uses some libraries (but not the
whole <*>.jar); using the "java -verbose" option you could know which
files have been loaded form the used library and either created a
smaller jar with all needed classes or, provided you have the source
code:
..
1._ replicate a source branch,
..
2._ recompile the "branched" source, and
..
3._ go: jar -cvf new_smaller.jar -C <branched_source> *.class
..
this is a pretty straight forward task and I was wondering if ant has
some kind of automation to achieve exactly this
..
Thanks
lbrtchx
 
D

Daniel Dyer

say you have an application that uses some libraries (but not the
whole <*>.jar); using the "java -verbose" option you could know which
files have been loaded form the used library and either created a
smaller jar with all needed classes or, provided you have the source
code:
.
1._ replicate a source branch,
.
2._ recompile the "branched" source, and
.
3._ go: jar -cvf new_smaller.jar -C <branched_source> *.class
.
this is a pretty straight forward task and I was wondering if ant has
some kind of automation to achieve exactly this
.

Properly configured, Proguard (http://proguard.sourceforge.net/) will do
something like this for you (among other things, primarily obfuscation).
It analyses the class files to see which library classes they depend on
and discards those that aren't used. This is probably safer because it
does not rely on you having to cover every possible execution path in
order to get a definitive list.

Dan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top