Determine Used Libraries To Reduce Jar File Size
Solution 1:
Do you really want to check all classes of all added libraries if they are needed or not?
IMHO this is a job for program. One popular open source program for doing so is ProGuard.
Generally ProGuard is known as obfuscator (rename everything in the class files so that understanding the decompiled classes is difficult) but it can be used without obfuscation when using the parameters -dontobfuscate. Additionally I suggest you to use the -dontoptimize parameter as well.
If you run ProGuard on you big fat JAR you will get a much smaller one.
If you are interested I could post a small part of an ant build file that shows how to configure and call ProGuard.
Solution 2:
You have to take into consideration not only the class you use directly, but all their dependencies as well. You'll have to chase down the entire object graph to figure out what's not called.
Solution 3:
I know about JBoss Tattletale, but I haven't tried it myself.
Keep in mind that a library might be accessed only during certain runs of the code (e.g. depending on the input), so it's very difficult to be certain whether a library might be needed.
If you get rid of some of the libraries, your application may work now, but fail on a different input, or fail when you start using HtmlUnit differently in your next release. 10 MB isn't so much nowadays, so maybe getting rid of some jars is not worth the trouble.
Post a Comment for "Determine Used Libraries To Reduce Jar File Size"