Minimizing jar dependency sizes

痴心易碎 提交于 2019-11-28 09:58:06

Proguard would be an option. It can eliminate unused classes and methods. You can also use it to obfuscate, which can further reduce the size of your final jar. Be aware that class loading by name is liable to break unless care is taken to keep the affected classes unobfuscated.

I've found Proguard quite effective - can be a bit cryptic to understand at the outset. But I don't have any experience with similar to offer a comparison.

First of all, if you use only one class from JAR file this does not mean that this class does not use other classed from that JAR. The option for you, if you use open source JARs, is to get sources of that JAR, attach them to your project, remove unnecessary stuff and build the changes by yourself.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!