Tag Archives: java.util.zip.zipexception

java.util.zip.zipexception: error in opening zip file

java.util.zip.ZipException: error in opening zip fileThe literal meaning of this question is that the compression package cannot be opened,
The problem I have here is that the JAR package is corrupted and won’t open.The Linux system can use the command to determine if the JAR is normal:

jar -vtf xxx.jar

view the jar archive directory

[root@localhost classes]# jar -h
Illegal options: h
Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
Options:
    -c create new file
    -t List archive directory
    -x Extracts specified (or all) files from the archive
    -u Update existing archives
    -v Generates detailed output from standard output
    -f Specify file name of file
    -m Contains inventory information from a specified inventory file
    -n Execute Pack200 normalization after creating a new profile
    -e for standalone applications that are bundled into the executable jar file
        Specifying application entry points
    -0 Storage only; does not use any ZIP compression
    -P Preserves leading '/' (absolute path) and "..." (parent directory) components in filenames (parent directory) components
    -M Inventory file without creating entries
    -i generates index information for a specified jar file
    -C changes to the specified directory and contains the following files
If any file is a directory, it is recursively processed.
Specify the order of the list file name, file name and entry point name.
in the same order as the 'm', 'f' and 'e' tags are specified.

Example 1: Archiving two class files into a file called classes.jar: 
       jar cvf classes.jar Foo.class Bar.class 
Example 2: Using an existing manifest file 'mymanifest' and the
           Archive all files from the foo/ directory into 'classes.jar':
       jar cvfm classes.jar mymanifest -C foo/ .

if it can be opened, it means it is normal; if it cannot be opened, it means the jar package is damaged:

The following error occurs:

java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:220)
at java.util.zip.ZipFile.<init>(ZipFile.java:150)
at java.util.jar.JarFile.<init>(JarFile.java:166)
at java.util.jar.JarFile.<init>(JarFile.java:130

The solution is to switch to a usable jar. If the jar isn’t working because of maven’s packaging, check out the blog: click the open link
Follow WeChat: community of programmers and developers