java.util.zip.ZipError: invalid CEN header (bad signature)

前端 未结 5 1434
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-11 10:23

I\'m using Java 1.7.0_40 on Red Hat Linux and I have the following code:

Path zipfile = Paths.get(filename);
FileSystem fs = FileSystems.newFileSystem(zipfil         


        
相关标签:
5条回答
  • 2021-01-11 10:44

    There are two possible explanations:

    • You have a corrupted ZIP file - Compile error in maven2: "invalid CEN header (bad signature)"

    • It is something to do with ZIP-64:

      • java.util.zip.ZipException: invalid CEN header (bad signature)

      • But also note that ZIP-64 support was only added in 1.7.0_b55; see https://bugs.openjdk.java.net/browse/JDK-4681995

    0 讨论(0)
  • 2021-01-11 10:52

    This problem occurs Due to jar file was downloaded is corrupted.

    if you are using Maven.

    • For Solving this issue, Delete Particular Jar File in C:/Users/public/.m2/repository folder.
    • After that add New Version of Maven in POM.xml.
    • Rebuild and try. It will work fine.
    0 讨论(0)
  • 2021-01-11 10:54

    Large file (4GB+) support for zip archives (i.e. 64-bit zip support) was addressed by issue JDK-4681995 ("Add support for large (> 4GB) zip/jar files").

    However, this change was not included in Java 7 until 1.7.0 build 55, which was a few builds after the specific version (1.7.0 build 40) that you were using. Updating to build 55 or later would solve the problem.

    0 讨论(0)
  • 2021-01-11 10:58

    I too faced the issue in Maven based project. The issue occurred because of corrupted jars. Deleted the jars from .m2 folder and built the project again; and it worked like charm.

    0 讨论(0)
  • 2021-01-11 11:09

    It is problem of configuration for maven compiler in your pom file. Default version java source and target is 1.5, even used JDK has higher version.

    To fix, add maven compiler plugin configuration section with higher java version, example:

    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.6.1</version>
      <configuration>
        <source>1.6</source>
        <target>1.6</target>
      </configuration>
    </plugin>
    

    For more info check these links:

    maven compiler

    bug report

    0 讨论(0)
提交回复
热议问题