Wednesday 2 March 2016

The pack200 Utility

Pack200 is an archive format that is optimized for storing compiled Java class files. Pack200 is not a new form of compression, but rather a super-efficient layout for class information that eliminates many types of waste and redundancy across related classes. It is effectively a bulk class-file format that deconstructs many classes and reassembles their parts efficiently into one catalog. This then allows a standard compression format like ZIP to work at maximum efficiency on the archive, achieving four or more times greater compression. The Java runtime does not understand the Pack200 format, so you cannot place archives of this type into the classpath. Instead, it is mainly an intermediate format that is very useful for transferring application JARs over the network for applets or other kinds of web-based applications. You can convert a JAR to and from Pack200 format with the pack200 and unpack200 commands supplied with the JDK. For example, to convert foo.jar to foo.pack.gz, use the pack200 command:

 % pack200 foo.pack.gz foo.jar    
To convert foo.pack.gz to foo.jar:
  
 % unpack200 foo.pack.gz foo.jar  
Note that the Pack200 process completely tears down and reconstructs your classes at the class level, so the resulting foo.jar file will not be byte-for-byte the same as the original.

0 comments:

Post a Comment