Extracting jar Manifest.mf is directory error












0















i try to unzip a jar to a specific location. It works for most of my libraries perfectly, but for 2, i get a error that the MANIFEST.MF is a directory.



My code:



public static void extract(File jar, String destination) throws IOException {

//Creates the Folder for Extracting
File outputFolder = new File(destination + File.separator + jar.getName());
if (!outputFolder.exists()) {
outputFolder.mkdir();
}

// Extract the Jar
ZipInputStream zis = new ZipInputStream(new FileInputStream(jar));
ZipEntry ze = zis.getNextEntry();

while (ze != null) {
String filePath = outputFolder + File.separator + ze.getName();
if (!ze.isDirectory()) {
//&& !ze.getName().contains("MANIFEST.MF")
// If the entry is a file, extract it, otherwise ...
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
byte bytesIn = new byte[BUFFER_SIZE];
int read = 0;
while ((read = zis.read(bytesIn)) != -1) {
bos.write(bytesIn, 0, read);
}
bos.close();
} else {
// ... create a directory
File dir = new File(filePath);
dir.mkdir();
}
// close entry and move on to the next one
zis.closeEntry();
ze = zis.getNextEntry();
}
zis.close();
}


And my console output:



Extract Jar: jackson-databind-2.9.1.jar
Extract Jar: guava-23.0.jar
Extract Jar: mockito-core-2.10.0.jar
Extract Jar: mockito-all-1.10.19.jar
Extract Jar: clojure-1.8.0.jar
Extract Jar: slf4j-log4j12-1.7.25.jar
Extract Jar: scala-library-2.13.0-M2.jar
java.io.FileNotFoundException: /home/tim/.m2/VulnerabilityChecker/TempFiles/scala-library-2.13.0-M2.jar/META-INF/MANIFEST.MF (Ist ein Verzeichnis)
Extract Jar: log4j-1.2.17.jar
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(FileOutputStream.java:276)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:220)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:109)
at HelperClasses.JarExtractor.extract(JarExtractor.java:94)
at libraryChecker.jarUtility.JarFinder.getSearchedJarFromList(JarFinder.java:46)
at libraryChecker.jarUtility.JarCrawler.searchForFittingJarFile(JarCrawler.java:18)
at schwachstellenkorrektursuche.LibraryChecker.start(LibraryChecker.java:86)
at schwachstellenkorrektursuche.Main.main(Main.java:9)
Extract Jar: javax.servlet-api-4.0.0.jar
Extract Jar: commons-lang-2.6.jar
Extract Jar: tools.nrepl-0.2.13.jar
Extract Jar: clojure-complete-0.2.4.jar
java.io.FileNotFoundException: /home/tim/.m2/VulnerabilityChecker/TempFiles/clojure-complete-0.2.4.jar/META-INF/MANIFEST.MF (Ist ein Verzeichnis)
at java.base/java.io.FileOutputStream.open0(Native Method)
at java.base/java.io.FileOutputStream.open(FileOutputStream.java:276)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:220)
at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:109)
at HelperClasses.JarExtractor.extract(JarExtractor.java:94)
at libraryChecker.jarUtility.JarFinder.getSearchedJarFromList(JarFinder.java:46)
at libraryChecker.jarUtility.JarCrawler.searchForFittingJarFile(JarCrawler.java:18)
at schwachstellenkorrektursuche.LibraryChecker.start(LibraryChecker.java:86)
at schwachstellenkorrektursuche.Main.main(Main.java:9)
Extract Jar: commons-lang3-3.6.jar
Extract Jar: maven-core-2.2.1.jar
Extract Jar: logback-classic-1.2.3.jar
Extract Jar: junit-4.12.jar
Extract Jar: slf4j-api-1.7.25.jar
Extract Jar: httpclient-4.5.3.jar
Extract Jar: maven-core-2.2.1-sources.jar
Extract Jar: commons-io-2.5.jar
Extract Jar: servlet-api-2.5.jar
Extract Jar: commons-logging-1.2.jar


The "Extract Jar: ... " get's called before the extract method is called, dont worry about that. My main idea is to ignore the MANIFEST.MF (see comment after the if-clause) if i cant find any solution, but i dont like this solution because i dont know if i need it at a later point and i am just curious why this happens... I thought i should ask some with more experience ;) Any thought's?










share|improve this question



























    0















    i try to unzip a jar to a specific location. It works for most of my libraries perfectly, but for 2, i get a error that the MANIFEST.MF is a directory.



    My code:



    public static void extract(File jar, String destination) throws IOException {

    //Creates the Folder for Extracting
    File outputFolder = new File(destination + File.separator + jar.getName());
    if (!outputFolder.exists()) {
    outputFolder.mkdir();
    }

    // Extract the Jar
    ZipInputStream zis = new ZipInputStream(new FileInputStream(jar));
    ZipEntry ze = zis.getNextEntry();

    while (ze != null) {
    String filePath = outputFolder + File.separator + ze.getName();
    if (!ze.isDirectory()) {
    //&& !ze.getName().contains("MANIFEST.MF")
    // If the entry is a file, extract it, otherwise ...
    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
    byte bytesIn = new byte[BUFFER_SIZE];
    int read = 0;
    while ((read = zis.read(bytesIn)) != -1) {
    bos.write(bytesIn, 0, read);
    }
    bos.close();
    } else {
    // ... create a directory
    File dir = new File(filePath);
    dir.mkdir();
    }
    // close entry and move on to the next one
    zis.closeEntry();
    ze = zis.getNextEntry();
    }
    zis.close();
    }


    And my console output:



    Extract Jar: jackson-databind-2.9.1.jar
    Extract Jar: guava-23.0.jar
    Extract Jar: mockito-core-2.10.0.jar
    Extract Jar: mockito-all-1.10.19.jar
    Extract Jar: clojure-1.8.0.jar
    Extract Jar: slf4j-log4j12-1.7.25.jar
    Extract Jar: scala-library-2.13.0-M2.jar
    java.io.FileNotFoundException: /home/tim/.m2/VulnerabilityChecker/TempFiles/scala-library-2.13.0-M2.jar/META-INF/MANIFEST.MF (Ist ein Verzeichnis)
    Extract Jar: log4j-1.2.17.jar
    at java.base/java.io.FileOutputStream.open0(Native Method)
    at java.base/java.io.FileOutputStream.open(FileOutputStream.java:276)
    at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:220)
    at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:109)
    at HelperClasses.JarExtractor.extract(JarExtractor.java:94)
    at libraryChecker.jarUtility.JarFinder.getSearchedJarFromList(JarFinder.java:46)
    at libraryChecker.jarUtility.JarCrawler.searchForFittingJarFile(JarCrawler.java:18)
    at schwachstellenkorrektursuche.LibraryChecker.start(LibraryChecker.java:86)
    at schwachstellenkorrektursuche.Main.main(Main.java:9)
    Extract Jar: javax.servlet-api-4.0.0.jar
    Extract Jar: commons-lang-2.6.jar
    Extract Jar: tools.nrepl-0.2.13.jar
    Extract Jar: clojure-complete-0.2.4.jar
    java.io.FileNotFoundException: /home/tim/.m2/VulnerabilityChecker/TempFiles/clojure-complete-0.2.4.jar/META-INF/MANIFEST.MF (Ist ein Verzeichnis)
    at java.base/java.io.FileOutputStream.open0(Native Method)
    at java.base/java.io.FileOutputStream.open(FileOutputStream.java:276)
    at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:220)
    at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:109)
    at HelperClasses.JarExtractor.extract(JarExtractor.java:94)
    at libraryChecker.jarUtility.JarFinder.getSearchedJarFromList(JarFinder.java:46)
    at libraryChecker.jarUtility.JarCrawler.searchForFittingJarFile(JarCrawler.java:18)
    at schwachstellenkorrektursuche.LibraryChecker.start(LibraryChecker.java:86)
    at schwachstellenkorrektursuche.Main.main(Main.java:9)
    Extract Jar: commons-lang3-3.6.jar
    Extract Jar: maven-core-2.2.1.jar
    Extract Jar: logback-classic-1.2.3.jar
    Extract Jar: junit-4.12.jar
    Extract Jar: slf4j-api-1.7.25.jar
    Extract Jar: httpclient-4.5.3.jar
    Extract Jar: maven-core-2.2.1-sources.jar
    Extract Jar: commons-io-2.5.jar
    Extract Jar: servlet-api-2.5.jar
    Extract Jar: commons-logging-1.2.jar


    The "Extract Jar: ... " get's called before the extract method is called, dont worry about that. My main idea is to ignore the MANIFEST.MF (see comment after the if-clause) if i cant find any solution, but i dont like this solution because i dont know if i need it at a later point and i am just curious why this happens... I thought i should ask some with more experience ;) Any thought's?










    share|improve this question

























      0












      0








      0








      i try to unzip a jar to a specific location. It works for most of my libraries perfectly, but for 2, i get a error that the MANIFEST.MF is a directory.



      My code:



      public static void extract(File jar, String destination) throws IOException {

      //Creates the Folder for Extracting
      File outputFolder = new File(destination + File.separator + jar.getName());
      if (!outputFolder.exists()) {
      outputFolder.mkdir();
      }

      // Extract the Jar
      ZipInputStream zis = new ZipInputStream(new FileInputStream(jar));
      ZipEntry ze = zis.getNextEntry();

      while (ze != null) {
      String filePath = outputFolder + File.separator + ze.getName();
      if (!ze.isDirectory()) {
      //&& !ze.getName().contains("MANIFEST.MF")
      // If the entry is a file, extract it, otherwise ...
      BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
      byte bytesIn = new byte[BUFFER_SIZE];
      int read = 0;
      while ((read = zis.read(bytesIn)) != -1) {
      bos.write(bytesIn, 0, read);
      }
      bos.close();
      } else {
      // ... create a directory
      File dir = new File(filePath);
      dir.mkdir();
      }
      // close entry and move on to the next one
      zis.closeEntry();
      ze = zis.getNextEntry();
      }
      zis.close();
      }


      And my console output:



      Extract Jar: jackson-databind-2.9.1.jar
      Extract Jar: guava-23.0.jar
      Extract Jar: mockito-core-2.10.0.jar
      Extract Jar: mockito-all-1.10.19.jar
      Extract Jar: clojure-1.8.0.jar
      Extract Jar: slf4j-log4j12-1.7.25.jar
      Extract Jar: scala-library-2.13.0-M2.jar
      java.io.FileNotFoundException: /home/tim/.m2/VulnerabilityChecker/TempFiles/scala-library-2.13.0-M2.jar/META-INF/MANIFEST.MF (Ist ein Verzeichnis)
      Extract Jar: log4j-1.2.17.jar
      at java.base/java.io.FileOutputStream.open0(Native Method)
      at java.base/java.io.FileOutputStream.open(FileOutputStream.java:276)
      at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:220)
      at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:109)
      at HelperClasses.JarExtractor.extract(JarExtractor.java:94)
      at libraryChecker.jarUtility.JarFinder.getSearchedJarFromList(JarFinder.java:46)
      at libraryChecker.jarUtility.JarCrawler.searchForFittingJarFile(JarCrawler.java:18)
      at schwachstellenkorrektursuche.LibraryChecker.start(LibraryChecker.java:86)
      at schwachstellenkorrektursuche.Main.main(Main.java:9)
      Extract Jar: javax.servlet-api-4.0.0.jar
      Extract Jar: commons-lang-2.6.jar
      Extract Jar: tools.nrepl-0.2.13.jar
      Extract Jar: clojure-complete-0.2.4.jar
      java.io.FileNotFoundException: /home/tim/.m2/VulnerabilityChecker/TempFiles/clojure-complete-0.2.4.jar/META-INF/MANIFEST.MF (Ist ein Verzeichnis)
      at java.base/java.io.FileOutputStream.open0(Native Method)
      at java.base/java.io.FileOutputStream.open(FileOutputStream.java:276)
      at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:220)
      at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:109)
      at HelperClasses.JarExtractor.extract(JarExtractor.java:94)
      at libraryChecker.jarUtility.JarFinder.getSearchedJarFromList(JarFinder.java:46)
      at libraryChecker.jarUtility.JarCrawler.searchForFittingJarFile(JarCrawler.java:18)
      at schwachstellenkorrektursuche.LibraryChecker.start(LibraryChecker.java:86)
      at schwachstellenkorrektursuche.Main.main(Main.java:9)
      Extract Jar: commons-lang3-3.6.jar
      Extract Jar: maven-core-2.2.1.jar
      Extract Jar: logback-classic-1.2.3.jar
      Extract Jar: junit-4.12.jar
      Extract Jar: slf4j-api-1.7.25.jar
      Extract Jar: httpclient-4.5.3.jar
      Extract Jar: maven-core-2.2.1-sources.jar
      Extract Jar: commons-io-2.5.jar
      Extract Jar: servlet-api-2.5.jar
      Extract Jar: commons-logging-1.2.jar


      The "Extract Jar: ... " get's called before the extract method is called, dont worry about that. My main idea is to ignore the MANIFEST.MF (see comment after the if-clause) if i cant find any solution, but i dont like this solution because i dont know if i need it at a later point and i am just curious why this happens... I thought i should ask some with more experience ;) Any thought's?










      share|improve this question














      i try to unzip a jar to a specific location. It works for most of my libraries perfectly, but for 2, i get a error that the MANIFEST.MF is a directory.



      My code:



      public static void extract(File jar, String destination) throws IOException {

      //Creates the Folder for Extracting
      File outputFolder = new File(destination + File.separator + jar.getName());
      if (!outputFolder.exists()) {
      outputFolder.mkdir();
      }

      // Extract the Jar
      ZipInputStream zis = new ZipInputStream(new FileInputStream(jar));
      ZipEntry ze = zis.getNextEntry();

      while (ze != null) {
      String filePath = outputFolder + File.separator + ze.getName();
      if (!ze.isDirectory()) {
      //&& !ze.getName().contains("MANIFEST.MF")
      // If the entry is a file, extract it, otherwise ...
      BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
      byte bytesIn = new byte[BUFFER_SIZE];
      int read = 0;
      while ((read = zis.read(bytesIn)) != -1) {
      bos.write(bytesIn, 0, read);
      }
      bos.close();
      } else {
      // ... create a directory
      File dir = new File(filePath);
      dir.mkdir();
      }
      // close entry and move on to the next one
      zis.closeEntry();
      ze = zis.getNextEntry();
      }
      zis.close();
      }


      And my console output:



      Extract Jar: jackson-databind-2.9.1.jar
      Extract Jar: guava-23.0.jar
      Extract Jar: mockito-core-2.10.0.jar
      Extract Jar: mockito-all-1.10.19.jar
      Extract Jar: clojure-1.8.0.jar
      Extract Jar: slf4j-log4j12-1.7.25.jar
      Extract Jar: scala-library-2.13.0-M2.jar
      java.io.FileNotFoundException: /home/tim/.m2/VulnerabilityChecker/TempFiles/scala-library-2.13.0-M2.jar/META-INF/MANIFEST.MF (Ist ein Verzeichnis)
      Extract Jar: log4j-1.2.17.jar
      at java.base/java.io.FileOutputStream.open0(Native Method)
      at java.base/java.io.FileOutputStream.open(FileOutputStream.java:276)
      at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:220)
      at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:109)
      at HelperClasses.JarExtractor.extract(JarExtractor.java:94)
      at libraryChecker.jarUtility.JarFinder.getSearchedJarFromList(JarFinder.java:46)
      at libraryChecker.jarUtility.JarCrawler.searchForFittingJarFile(JarCrawler.java:18)
      at schwachstellenkorrektursuche.LibraryChecker.start(LibraryChecker.java:86)
      at schwachstellenkorrektursuche.Main.main(Main.java:9)
      Extract Jar: javax.servlet-api-4.0.0.jar
      Extract Jar: commons-lang-2.6.jar
      Extract Jar: tools.nrepl-0.2.13.jar
      Extract Jar: clojure-complete-0.2.4.jar
      java.io.FileNotFoundException: /home/tim/.m2/VulnerabilityChecker/TempFiles/clojure-complete-0.2.4.jar/META-INF/MANIFEST.MF (Ist ein Verzeichnis)
      at java.base/java.io.FileOutputStream.open0(Native Method)
      at java.base/java.io.FileOutputStream.open(FileOutputStream.java:276)
      at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:220)
      at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:109)
      at HelperClasses.JarExtractor.extract(JarExtractor.java:94)
      at libraryChecker.jarUtility.JarFinder.getSearchedJarFromList(JarFinder.java:46)
      at libraryChecker.jarUtility.JarCrawler.searchForFittingJarFile(JarCrawler.java:18)
      at schwachstellenkorrektursuche.LibraryChecker.start(LibraryChecker.java:86)
      at schwachstellenkorrektursuche.Main.main(Main.java:9)
      Extract Jar: commons-lang3-3.6.jar
      Extract Jar: maven-core-2.2.1.jar
      Extract Jar: logback-classic-1.2.3.jar
      Extract Jar: junit-4.12.jar
      Extract Jar: slf4j-api-1.7.25.jar
      Extract Jar: httpclient-4.5.3.jar
      Extract Jar: maven-core-2.2.1-sources.jar
      Extract Jar: commons-io-2.5.jar
      Extract Jar: servlet-api-2.5.jar
      Extract Jar: commons-logging-1.2.jar


      The "Extract Jar: ... " get's called before the extract method is called, dont worry about that. My main idea is to ignore the MANIFEST.MF (see comment after the if-clause) if i cant find any solution, but i dont like this solution because i dont know if i need it at a later point and i am just curious why this happens... I thought i should ask some with more experience ;) Any thought's?







      java manifest unzip






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 19 at 13:47









      MechamodMechamod

      15




      15
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54267739%2fextracting-jar-manifest-mf-is-directory-error%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54267739%2fextracting-jar-manifest-mf-is-directory-error%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Liquibase includeAll doesn't find base path

          How to use setInterval in EJS file?

          Petrus Granier-Deferre