pack200 [ options ] output-file JAR-file
Options may be in any order. The last option on the command line or in a properties file supersedes all previously specified options.
The pack200 tool is a Java application that transforms a JAR file into a compressed pack200 file using the Java gzip compressor. The pack200 files are highly compressed files that can be directly deployed, saving bandwidth and reducing download time.
The pack200 tool uses several options to fine-tune and set the compression engine.
In this example, myarchive.pack.gz is produced using the default pack200 settings.
Produces a JAR file by packing the file myarchive.jar and unpacking it. The resulting file can be used as an input to the jarsigner(1) tool.
Produces a pack200 file. With this option a suitable compressor must be used, and the target system must use a corresponding decompresser.
Strips attributes used for debugging from the output. These include SourceFile, LineNumberTable, LocalVariableTable and LocalVariableTypeTable. Removing these attributes reduces the size of both downloads and installations but reduces the usefulness of debuggers.
The packer will reorder and transmit all elements. Additionally, the packer may remove JAR directory names. This will reduce the download size; however, certain JAR file optimizations, such as indexing, may not work correctly.
The value is the estimated target size N (in bytes) of each archive segment. If a single input file requires
more than N bytes, it will be given its own archive segment. As a special case, a value of -1 will produce a single large segment with all input files, while a value of 0 will produce one segment for each class. Larger archive segments result in less fragmentation and better compression, but processing them requires more memory.
The size of each segment is estimated by counting the size of each input file to be transmitted in the segment, along with the size of its name and other transmitted properties.
The default is 1000000 (a million bytes). This allows input JAR files of moderate size to be transmitted in one segment. It also puts a limit on memory requirements for packers and unpackers.
A 10MB JAR packed without this limit will typically pack about 10% smaller, but the packer may require a larger Java heap (about ten times the segment limit).
If the value is set to a single decimal digit, the packer will use the indicated amount of effort in compressing the archive. Level 1 may produce somewhat larger size and faster compression speed, while level 9 will take much longer but may produce better compression. The special value 0 instructs the packer to copy through the original JAR file directly with no compression. The JSR 200 standard requires any unpacker to understand this special case as a pass-through of the entire archive.
The default is 5, investing a modest amount of time to produce reasonable compression.
Overrides the default, which preserves the input information, but may cause the transmitted archive to be larger. The possible values are:
The possible values are:
Indicates that a file should be passed through bytewise with no compression. By repeating the option, multiple files may be specified. There is no pathname transformation, except that the system file separator is replaced by the JAR file separator "/". The resulting file names must match exactly as strings with their occurrences in the JAR file. If file is a directory name, all files under that directory will be passed.
Overrides the default behavior; i.e., the classfile containing the unknown attribute will be passed through with the specified action. The possible values for actions are:
With the above four options, the attribute layout can be specified for a class entity, such as Class attribute, Field attribute, Method attribute, and Code attribute. The attribute-name is the name of the attribute for which the layout or action is being defined. The possible values for action are:
Example: --class-attribute=CompilationID=pass will cause the class file containing this attribute to be passed through without further action by the packer.
-f pack.properties --config-file=pack.properties
A configuration file, containing Java properties to initialize the packer, may be specified on the command line.
Outputs minimal messages. Multiple specification of this option will output more verbose messages.
Specifies quiet operation with no messages.
Specifies a log file to output messages.
Passes option to the Java launcher called by pack200. For example, -J-Xms48m sets the startup memory to 48 megabytes. Although it does not begin with -X, it is not a standard option of pack200. It is a common convention for -J to pass options to the underlying VM executing applications written in Java.
The following exit values are returned:
0 for successful completion;
>0 if an error occurs.
This command should not be confused with pack(1). They are distinctly separate products.
The Java SE API Specification provided with the SDK is the superseding authority, in case of discrepancies.