This version is still in development and is not considered stable yet. For the latest stable version, please use Compress4J 5.x!

Additional Formats

Some formats may require additional support libraries to be included in your project. Below are some common formats and the corresponding libraries you may need:

XZ Support

XZ and LZMA support needs org.tukaani:xz on the class path or module path. There is no separate Compress4J artifact; the former compress4j-xz-support capability and its io.github.compress4j.xz automatic module name no longer exist, so remove them from your build and module-info.java.

On the module path, org.tukaani.xz is not resolved automatically. Add requires org.tukaani.xz; to your module, or start the JVM with --add-modules org.tukaani.xz.

  • Maven

  • Gradle Groovy

  • Gradle Kotlin

<dependency>
    <groupId>com.hominux</groupId>
    <artifactId>compress4j</artifactId>
    <version>YOUR_VERSION</version>
</dependency>
<dependency>
    <groupId>org.tukaani</groupId>
    <artifactId>xz</artifactId>
    <version>YOUR_XZ_VERSION</version>
</dependency>
dependencies {
    implementation 'com.hominux:compress4j:YOUR_VERSION'
    implementation 'org.tukaani:xz:YOUR_XZ_VERSION'
}
dependencies {
    implementation("com.hominux:compress4j:YOUR_VERSION")
    implementation("org.tukaani:xz:YOUR_XZ_VERSION")
}

Zstandard Support

Zstandard support needs com.github.luben:zstd-jni on the class path or module path. It ships native libraries for common platforms.

On the module path, com.github.luben.zstd_jni is not resolved automatically. Add requires com.github.luben.zstd_jni; to your module, or start the JVM with --add-modules com.github.luben.zstd_jni.

  • Maven

  • Gradle Groovy

  • Gradle Kotlin

<dependency>
    <groupId>com.hominux</groupId>
    <artifactId>compress4j</artifactId>
    <version>YOUR_VERSION</version>
</dependency>
<dependency>
    <groupId>com.github.luben</groupId>
    <artifactId>zstd-jni</artifactId>
    <version>YOUR_ZSTD_JNI_VERSION</version>
</dependency>
dependencies {
    implementation 'com.hominux:compress4j:YOUR_VERSION'
    implementation 'com.github.luben:zstd-jni:YOUR_ZSTD_JNI_VERSION'
}
dependencies {
    implementation("com.hominux:compress4j:YOUR_VERSION")
    implementation("com.github.luben:zstd-jni:YOUR_ZSTD_JNI_VERSION")
}

Brotli Support

Brotli support needs org.brotli:dec on the class path or module path. It only reads Brotli data; see Read-only formats.

The org.brotli:dec jar has no module descriptor, so its module name is derived from the file name (dec). On the module path, start the JVM with --add-modules dec.

  • Maven

  • Gradle Groovy

  • Gradle Kotlin

<dependency>
    <groupId>com.hominux</groupId>
    <artifactId>compress4j</artifactId>
    <version>YOUR_VERSION</version>
</dependency>
<dependency>
    <groupId>org.brotli</groupId>
    <artifactId>dec</artifactId>
    <version>YOUR_BROTLI_DEC_VERSION</version>
</dependency>
dependencies {
    implementation 'com.hominux:compress4j:YOUR_VERSION'
    implementation 'org.brotli:dec:YOUR_BROTLI_DEC_VERSION'
}
dependencies {
    implementation("com.hominux:compress4j:YOUR_VERSION")
    implementation("org.brotli:dec:YOUR_BROTLI_DEC_VERSION")
}

Pack200 Support

Writing Pack200 needs org.ow2.asm:asm on the class path. Without it, opening a Pack200 write throws MissingArchiveDependencyException. Compress4J is tested against ASM 9.11.

  • Maven

  • Gradle Groovy

  • Gradle Kotlin

<dependency>
    <groupId>com.hominux</groupId>
    <artifactId>compress4j</artifactId>
    <version>YOUR_VERSION</version>
</dependency>
<dependency>
    <groupId>org.ow2.asm</groupId>
    <artifactId>asm</artifactId>
    <version>YOUR_ASM_VERSION</version>
</dependency>
dependencies {
    implementation 'com.hominux:compress4j:YOUR_VERSION'
    implementation 'org.ow2.asm:asm:YOUR_ASM_VERSION'
}
dependencies {
    implementation("com.hominux:compress4j:YOUR_VERSION")
    implementation("org.ow2.asm:asm:YOUR_ASM_VERSION")
}