Apache compression using 7zip

I am trying to use the code below that I received from apache commons to compress web page examples to create a zip file using the seven Z classes, hoping to compress faster than regular java-zip. this is my code looks like

public static void main(String[] args) {
    // TODO Auto-generated method stub
    try{
    BufferedInputStream instream = new BufferedInputStream(new FileInputStream("c:/temp/test.txt"));

    SevenZOutputFile sevenZOutput = new SevenZOutputFile(new File("c:/temp/7ztest.zip"));
    SevenZArchiveEntry entry = sevenZOutput.createArchiveEntry(new File("c:/temp/test.txt"),"blah.txt");
    sevenZOutput.putArchiveEntry(entry);
    byte[] buffer = new byte[1024];
    int len;
    while ((len = instream.read(buffer)) > 0) {sevenZOutput.write(buffer, 0, len);}

    sevenZOutput.closeArchiveEntry();
    sevenZOutput.close();
    instream.close();
    }catch(IOException ioe) {
        System.out.println(ioe.toString());

    }
}

I get this error that looks so disconnected

Exception in the main thread java.lang.NoClassDefFoundError: org.tukaani.xz.FilterOptions in java.lang.J9VMInternals.verifyImpl (native method) in java.lang.J9VMInternals.verify (J9VMInternals.java:93)

I have apache packages imported

import org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry; import org.apache.commons.compress.archivers.sevenz.SevenZOutputFile;

, org.tukaani.xz.FilterOptions, , apace commons. ?

+4
1

Apache Commons:

" XZ Java.

, 7zip.

<dependency>
  <groupId>org.tukaani</groupId>
  <artifactId>xz</artifactId>
  <version>1.5</version>
</dependency>
+12

All Articles