Support This Project SourceForge.net Logo
LogoLogo Big

What's this all about?

7-Zip-JBinding is a java wrapper for 7-Zip C++ library. It allows extraction of many archive formats using a very fast native library directly from java through JNI. Features:

  • Extraction of
    7-Zip Zip Rar Tar Split Lzma Iso HFS GZip
    Cpio BZip2 Z Arj Chm Lhz Cab Nsis
    Deb Rpm Wim Udf
  • It's cross-platform. Binaries are available for
    › MS-Windows 32/64 › Linux 32/64 › Darwin Mac OS X
  • Full support for password protected and volumed archives
  • 12 example code snippets
  • Over 3881 JUnit tests: Dashboard
  • Planned: Creation of 7-Zip/Zip archives
  • Planned: Extraction of more archive formats: Compound, Dmg, Elf, Hfs, Macho, Mub, Pa, Split, Wim

How does it work?

The 7-Zip-JBinding consists of two parts: the java part and the native part. The java part introduces a cross-platform java interface of the 7-Zip library. The native part of 7-Zip-JBinding communicates with the java part through the java jni interface and uses the corresponding native 7-Zip interface to perform operations.

Overview


It's really simple!

Getting number of packed items in an archive:

private int getNumberOfItemsInArchive(String archiveFile) throws Exception {
    ISevenZipInArchive archive;
    RandomAccessFile randomAccessFile;

    randomAccessFile = new RandomAccessFile(archiveFile, "r");

    archive = SevenZip.openInArchive(ArchiveFormat.ZIP, // null - autodetect
            new RandomAccessFileInStream(
                    randomAccessFile));

    int numberOfItems = archive.getNumberOfItems();

    archive.close();
    randomAccessFile.close();

    return numberOfItems;
}

For the sake of simplicity all error handling was skipped. Continue with first steps for more examples and explanations.


News

16 Januar 2013: 7-Zip-JBinding Release: 4.65-1.06rc-extr-only

Release candidate, extraction only, cross-platform, based on 7zip/p7zip 4.65
  • Feature: WIM format support + tests
  • Feature: Initialization performance boost. Don't delete extracted native libraries in the temporary directory (specified by -Djava.io.tmpdir=<dir>) and use those later during subsequent 7-Zip-JBinding initializations.
  • Test: Test cross-platform encoding functionality
  • Bugfix: Get ride of the dependency to USER32.DLL improving performance and robustness
  • Bugfix: 7-Zip-JBinding compiles now with gcc 4.7 (Bug ID: 3593757)
    Special thanks to Daniel Santos for the provided patch!
  • Bugfix: Simple Interface returns wrong CRC (Bug ID: 3535546)
    Special thanks to M. Hamer

24 April 2012: 7-Zip-JBinding Release: 4.65-1.05rc-extr-only

Release candidate, extraction only, cross-platform, based on 7zip/p7zip 4.65
  • Bugfix: Multipart CAB-archive extraction without implementing IArchiveOpenVolumeCallback
  • Bugfix: A general protection fault raises when trying to list files in passworded RAR archive. The password length is 30+ characters.
  • Feature: Initialize native module within a AccessController#doPrivileged block

8 March 2010: 7-Zip-JBinding Release: 4.65-1.04rc-extr-only

Release candidate, extraction only, cross-platform, based on 7zip/p7zip 4.65
  • Bugfix: it was not possible to open some archives over 4GB
    Special thanks for IKVM developer Jeroen Frijters for finding this bug!

9 December 2009: 7-Zip-JBinding Release: 4.65-1.03rc-extr-only

Release candidate, extraction only, cross-platform, based on 7zip/p7zip 4.65
  • Binary version for MacOS 64 bit (java 6)
  • Support for multi-platform jars. Multi-platform releases:
    • AllPlatforms - all available native libraries in a single jar
    • AllWindows - native libraries for Windows 32 and 64
    • AllLinux - native libraries for Linux 32 and 64
    • AllMac - native libraries for Mac 32 and 64
  • Initialization reworked. See JavaDoc for SevenZip for more information.
  • Integration test for all platforms for single and multiple platform distributions
  • Improved ISevenZipInArchive.extract(): Sort indices, if not already sorted, bug fixes.
  • DEB format support + tests
  • RPM format support + tests
  • UDF format support + tests
  • New Code snippets: opening multi-part 7z and RAR archives
  • Source code repository: moved from svn to git

9 October 2009: 7-Zip-JBinding Release: 4.65-1.02rc-extr-only

Bugfix release (Release candidate, extraction only, cross-platform, based on 7zip/p7zip 4.65)
  • Binary version for Windows 64 XP and above (amd64)
  • NSIS format support + tests
  • New method ISevenZipInArchive.getArchiveFormat() returns format of the opened archive, even if archive format auto-detection was used.
  • Better performance for archive format auto-detection

1 September 2009: 7-Zip-JBinding Release: 4.65-1.01rc-extr-only

Bugfix release (Release candidate, extraction only, cross-platform, based on 7zip/p7zip 4.65)
31 July 2009: 7-Zip-JBinding Release: 4.65-1.0rc-extr-only

The first cross-platform release of Java wrapper for 7-Zip library was build!
Main features of 4.65-1.0rc-extr-only (Release candidate, extraction only, cross-platform, based on 7zip/p7zip 4.65)
  • Extraction of 7z, Zip, Tar, Split, Rar, Lzma, Iso, HFS, GZip, Cpio, BZIP2, Z, Arj
  • Support for password protected and volumed archives
  • Compression method auto detection
  • Simple extraction interface
  • Cross-platform. Binaries available for
    • Windows 32
    • Linux 32/64
    • Mac OS X
  • Over 3000 JUnit tests extraction of archive formats: 7z, Arj, BZip2, Cpio, GZip, ISO, Lzma, Rar, Tar, Z, Zip
  • 7-Zip-JBinding requires Java 1.5 or higher

30 January 2009: 7-Zip-JBinding Release: 0.4.1
  • Bug fixed: 2525877 (Memory leak)

4 January 2009: 7-Zip-JBinding Release: 0.4
  • Full rework of c++ code: thread safe JNI-calls, correct exception handling between threads
  • Bug #2441909 fixed (Can't extract encrypted 7-Zip files)
  • New open/extract method for crypted archives and items (standard and simple interface)
  • JUnit tests for the extraction of crypted archives and exception handling
  • New examples on the home page
more news