pack200(1) | Java Deployment Tools | pack200(1) |
pack200 - Packages a JAR file into a compressed pack200 file for web deployment.
pack200 [options] output-file JAR-file
Options can be in any order. The last option on the command line or in a properties file supersedes all previously specified options.
The pack200 command is a Java application that transforms a JAR file into a compressed pack200 file with the Java gzip compressor. The pack200 files are highly compressed files that can be directly deployed to save bandwidth and reduce download time.
The pack200 command has several options to fine-tune and set the compression engine. The typical usage is shown in the following example, where myarchive.pack.gz is produced with the default pack200 command settings:
pack200 myarchive.pack.gz myarchive.jar
pack200 --repack myarchive-packer.jar myarchive.jar
pack200 --repack myarchive.jar
The following example preserves the order of files in the input file.
pack200 --no-gzip myarchive.pack myarchive.jar
The size of each segment is estimated by counting the size of each input file to be transmitted in the segment with the size of its name and other transmitted properties.
The default is -1, which means that the packer creates a single segment output file. In cases where extremely large output files are generated, users are strongly encouraged to use segmenting or break up the input file into smaller JARs.
A 10 MB JAR packed without this limit typically packs about 10 percent smaller, but the packer might require a larger Java heap (about 10 times the segment limit).
The default is 5, to invest a modest amount of time to produce reasonable compression.
If the value is true or false, then the packer200 command sets the deflation hint accordingly in the output archive and does not transmit the individual deflation hints of archive elements.
The keep value preserves deflation hints observed in the input JAR. This is the default.
If the value is latest, then the packer attempts to determine the latest modification time, among all the available entries in the original archive, or the latest modification time of all the available entries in that segment. This single value is transmitted as part of the segment and applied to all the entries in each segment. This can marginally decrease the transmitted size of the archive at the expense of setting all installed files to a single date.
If the value is keep, then modification times observed in the input JAR are preserved. This is the default.
If the value is error, then the entire pack200 command operation fails with a suitable explanation.
If the value is strip, then the attribute is dropped. Removing the required Java Virtual Machine (JVM) attributes can cause class loader failures.
If the value is pass, then the entire class is transmitted as though it is a resource.
See next option.
See next option.
See next option.
With the previous 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 some-layout-string, error, strip, pass.
some-layout-string: The layout language is defined in the JSR 200 specification, for example: --class-attribute=SourceFile=RUH.
If the value is error, then the pack200 operation fails with an explanation.
If the value is strip, then the attribute is removed from the output. Removing JVM-required attributes can cause class loader failures. For example, --class-attribute=CompilationID=pass causes the class file that contains this attribute to be passed through without further action by the packer.
If the value is pass, then the entire class is transmitted as though it is a resource.
pack200 -f pack.properties myarchive.pack.gz myarchive.jar
more pack.properties
# Generic properties for the packer.
modification.time=latest
deflate.hint=false
keep.file.order=false
# This option will cause the files bearing new attributes to
# be reported as an error rather than passed uncompressed.
unknown.attribute=error
# Change the segment limit to be unlimited.
segment.limit=-1
The following exit values are returned: 0 for successful completion and a number greater than 0 when an error occurs.
This command should not be confused with pack(1). The pack and pack200 commands are separate products.
The Java SE API Specification provided with the JDK is the superseding authority, when there are discrepancies.
21 November 2013 | JDK 8 |