title: Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream
body: <p>I'm trying to create docx file in Java using Apache POI.
  Here is my code..</p>
  
  <pre><code>import java.io.File;
  import java.io.FileOutputStream;
  import org.apache.poi.xwpf.usermodel.XWPFDocument;
  import org.apache.poi.xwpf.usermodel.XWPFParagraph;
  import org.apache.poi.xwpf.usermodel.XWPFRun;
  
  public class DocGen {
  
  
  
      private static void createDocFile(String fileName) {
          // TODO Auto-generated method stub
          try {
              File file = new File(fileName);
              FileOutputStream fos = new FileOutputStream(file.getAbsolutePath());
  
              XWPFDocument doc1 = new XWPFDocument();
              XWPFParagraph tempParagraph = doc1.createParagraph();
              XWPFRun tempRun = tempParagraph.createRun();
  
              tempRun.setText("-----Demo Paragraph-----");
              tempRun.setFontSize(12);
              doc1.write(fos);
              fos.close();
              doc1.close();
              System.out.println("-----------File Created At---------"+file.getAbsolutePath());
  
  
          }catch(Exception e) {
              System.out.println("-----Exception------"+e);
          }
  
      }
  
      public static void main(String[] args) {
          // TODO Auto-generated method stub
          createDocFile("/home/yashpatel/Documents/Doc1.docx");
          createDocFile("/home/yashpatel/Documents/Doc1.doc");
      }
  
  }
  </code></pre>
  
  <p>Following are the jar files I have added..
  <a href="https://i.stack.imgur.com/9pu01.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9pu01.png" alt="enter image description here"></a></p>
  
  <p>I am getting the following error..</p>
  
  <blockquote>
    <p>Exception in thread "main" java.lang.NoClassDefFoundError:
    org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream  at
    org.apache.poi.openxml4j.opc.OPCPackage.create(OPCPackage.java:365)
      at
    org.apache.poi.xwpf.usermodel.XWPFDocument.newPackage(XWPFDocument.java:158)
      at
    org.apache.poi.xwpf.usermodel.XWPFDocument.(XWPFDocument.java:149)
      at DocGen.createDocFile(DocGen.java:17)     at
    DocGen.main(DocGen.java:37) Caused by:
    java.lang.ClassNotFoundException:
    org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream  at
    java.net.URLClassLoader.findClass(URLClassLoader.java:381)    at
    java.lang.ClassLoader.loadClass(ClassLoader.java:424)     at
    sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)     at
    java.lang.ClassLoader.loadClass(ClassLoader.java:357)     ... 5 more</p>
  </blockquote>