Pack200 is a method to compress JAR files very efficiently. The compression ratio depends on the density and size of the class files in the JAR. Pack200 compression IS NOT lossless. The redundant class attributes are removed, the constant-pool data in the class files is merged, sorted and co-located in the archive.
The Pack200 compression method requires JRE v1.5 or later installed on the target machine or bundled within your application. In case you don't use only the package with bundle JRE, you should have such a JRE as Prerequisites.
Being a lossy data compression, Pack200 requires all JAR files, packed and unpacked, be tested for correctness.
Packing signed JAR files
Because the pack/unpack process rearranges the contents of the resultant JAR, the file signature can be broken. Therefore, the JAR file must be normalized first and only after signed.
Steps for signing JAR files in order to be packed with Pack200:
- To normalize a JAR file you must use the pack200.exe application
from the JAVA_HOME\bin folder. The command line you should use when
you normalize the JAR file depends on the compression level specified
in the Builds page:
- Fastest: pack200 --repack --effort=2 --segment-limit=0 file.jar
- Fast: pack200 --repack --effort=4 --segment-limit=500000 file.jar
- Normal: pack200 --repack file.jar
- Good: pack200 --repack --effort=7 --segment-limit=10000000 --modification-time=latest file.jar
- Best: pack200 --repack --effort=9 --segment-limit=-1 --modification-time=latest --strip-debug file.jar
- Sign the JAR file using your signing tool.
It is not recommended to use the packing compression method on obfuscated signed JAR files.
Reducing JAR size
In order to obtain higher compression rates, the following options are used: