Alex Rivera | Logout

Minimizing jar dependency sizes

Asked 2010-09-28T23:09:47.857
12

an application I have written uses several third party jars. Sometimes only a small portion of the entire 50kB to 1.7mB jar is used - one or two function calls or classes.

What is the best way to reduce the jar sizes. Should I download the sources and build a jar with just the classes I need? What existing tools can help automate this (ex I briefly looked at http://code.google.com/p/jarjar/)?

Thank you

Edit 1: I would like to lower the size of my third party 'official' jars like swingx-1.6.jar (1.4 MB), set-3.6 (1.7 MB) glazedlists-1.8.jar (820kB) , etc. so that they only contain the bare minimum classes I need

Edit 2: Minimizing a jar by hand or by using a program like proguard is further complicated if the library uses reflection. Injection with google guice does not work anymore after obfuscation with proguard

The answer by cletus on another post is very good How to determine which classes are used by a Java program?

Edit
Report

1 Answer

0

You could add GenJar as an Ant task and use it to build the JAR. As it says on the library's home page,

GenJar is a specialized Ant task that builds jar files based on class dependencies rather than simply the contents of a directory.

You can find it on SourceForge.

answered 2010-09-29T10:03:41.050

Your Answer