Adam Bien's Weblog
How to reduce the Jar-File size with Java5 and 6
Java SE 5 and 6 comes already with a packing tool called "pack200". This tool is able to compress already existing jar files which can be then used for network distribution. I compressed the rt.jar with the following command:
C:\Programme\Java\jdk1.6.0\jre\lib>pack200 -J-Xmx256m rt.jar.gz rt.jar
The flag -J-X.. is needed, because otherwise OutOfMemory exception can occur (pack200 is written in Java...)
The results are amazing:
Origin size: 43.8 MB
Compressed size: 5.81 MB
For unpacking the tool "unpack200" can be used.
The tool pack200 is especially interesting for the distribution of WebStart applications to achieve faster download times. There is already one another well known sample - glassfish. In the second installation stage, glassfish unpacks internal libraries using the unpack200 tool...
Special Events: Java 8 with Java EE 7: "More Power with Less Code", 13th October, 2014 and Java EE 7: "Testing and Code Quality", 14th October, 2014 Tweet Follow @AdamBien