Reducing jar file size? [duplicate]

情到浓时终转凉″ 提交于 2019-12-01 03:13:12

Yes, there is one - Proguard.

ProGuard is a free Java class file shrinker, optimizer, obfuscator, and preverifier. It detects and removes unused classes, fields, methods, and attributes. It optimizes bytecode and removes unused instructions. It renames the remaining classes, fields, and methods using short meaningless names. Finally, it preverifies the processed code for Java 6 or for Java Micro Edition.

Obfuscation typically reduces jar file size by a respectable factor.

You may want to try tools like Proguard (open source) and similar.

You can see some examples of size reduction in this page:

Just another nice trick, usually using the unnamed package, which is deleting the name (< default> will appear), also decreases the jar size.

In my case my jar went from 24,243 bytes to 23,946. Yeah not a big deal but still a cool trick i think.

From efficient MIDP programming:

"Use the 'unnamed package' – placing your MIDlet classes all in the same named package only increases the size of your MIDlet’s JAR file; reserve the package statement for libraries" http://carfield.com.hk/document/java/articles/Efficient_MIDP_Programming.pdf

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