Pack200
Pack200 is a compression scheme for JAR files, designed to significantly reduce the size of Java archives. It is useful for distributing Java applications and libraries more efficiently.
Features
-
Compresses JAR files into
.packformat -
Decompresses
.packfiles back to JAR -
Useful for reducing download sizes
Usage Example
The following Java example demonstrates how to compress and decompress a JAR file using Pack200:
Pack200 Creation
Path sourceJar = Path.of("example.jar");
Path targetPack = Path.of("example.pack");
try (var compressor = Pack200Compressor.builder(targetPack).build()) {
compressor.write(sourceJar);
}
Pack200 Extraction
Path sourcePack = Path.of("example.pack");
Path targetJar = Path.of("example.jar");
try (var decompressor = Pack200Decompressor.builder(sourcePack).build()) {
decompressor.write(targetJar);
}
|
Removal of Pack200 Tools and API
The Pack200 tools and API were deprecated in JDK 11 and have been removed in JDK 14. The pack200 and unpack200 tools, and Pack200 in java.util.jar.Pack200 package have been removed . |