The Issue
I am unable to compile Java code for an imported Eclipse project on IntelliJ build 182.4505.22 on Java 9 and 10. The following error is displayed when compiling the module, or any individual file:
Error:(1, 1) java: cannot access edu.wit.cs.comp2000
zip END header not found
Details
The structure of the project is as follows:
The full compile-time output is as follows:
Already Attempted
I have reviewed posts here and here, which do not provide any relevant details.
I have attempted compiling on both Java 9 and 10, which makes no difference.
I have written a main method into LinkedBag and attempted to run that independent of JUnit, which results in the same error.
IntelliJ is not correctly displaying the testing icons in my test class, so I suspect that JUnit (or lack of JUnit) is the cause of the issue, however I am unsure how to proceed. Compiling works for other projects (without JUnit tests) just fine.
Updates
- The code seems to compile and test as expected on Java 1.8 without issue. Switching to Java 9 or 10 causes the above issue every time. I am beginning to suspect that one of my instructor’s dependencies requires Java 1.8 specifically, however I would still like to use newer versions of Java if anyone might have a solution.
asked Sep 19, 2018 at 17:58
J. BlackadarJ. Blackadar
1,7911 gold badge10 silver badges18 bronze badges
3
As mentioned above, just delete the corrupted cache and restart Intellij.
Running gradle in the commandline can help knowing what you should delete. For instance:
$ ./gradlew --version
Could not unzip /home/cesarc/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb/gradle-5.6.2-all.zip to /home/cesarc/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb.
Reason: error in opening zip file
and after deleting the folder /home/cesarc/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb the problem was solved:
$ ./gradlew --version
Downloading https://services.gradle.org/distributions/gradle-5.6.2-all.zip
......
answered Dec 23, 2019 at 13:36
2
We had this issue when internet connection dropped while Idea was downloading project dependencies. We solved it by deleting the corrupted file from cache. Cache location depends on your build tool, e. g. for Maven it’s in ~/.mvn
, for Gradle it’s in ~/.gradle
.
answered Dec 16, 2019 at 13:59
dizeeedizeee
3802 silver badges7 bronze badges
1
In my case, it was: /.m2/repository/org/apache/tomcat/embed/tomcat-embed-core/9.0.41/tomcat-embed-core-9.0.41.jar
I just removed it and I was able to compile my code.
Just pay attention to the .jar file in your case it’s giving an error. Just remove it and you are good to go.
answered Dec 24, 2020 at 18:21
I Had Similar issue in my mac.I just deleted .m2 repository and did maven clean install again worked.
answered Apr 10, 2020 at 20:30
Rocky4EverRocky4Ever
7983 gold badges11 silver badges31 bronze badges
1
Instead of deleting your whole maven repository you can scan through it locally to find the bad jar file using GNU utils
find <maven-repository-dir> -type f -name "*.jar" -exec zip -T {} ; grep -v OK
answered Oct 12, 2022 at 12:56
1
I got this error
[ERROR] error reading /Users/username/.m2/repository/io/confluent/common-config/5.5.1/common-config-5.5.1.jar; zip END header not found
I don’t know why the jar was corrupted but the error went away when I replaced the jar with my colleagues jar file. Fixing the error temporarily.
answered Mar 10, 2021 at 9:08
SwootSwoot
1,28411 silver badges12 bronze badges
In my case, the gradle version of the project was 6.2.2 and the 6.4.1(system default gradle) path was provided in the Intellij gradle settings.
This issue appeared suddenly though. I was working on this project for a long time without any issues. I am not quite sure as to what triggered this issue. The gradle default version package was fine as the gradle build was fine from command line.
Referred to suggestions from here
Any one of the below solved the issue on my system:
- Provide the path to project gradle version, in gradle settings.
or - Change the ‘distributionUrl’ value in your gradle-wrapper.properties to have ‘all’ instead of ‘bin’. And also make sure you have gradle-wrapper.properties configured in your intellij gradle settings.
distributionUrl=https://services.gradle.org/distributions/gradle-6.2.2-all.zip
answered Jun 5, 2020 at 12:37
This can also occurs when you use a dependency that requires to be of type pom
(to transitively add all dependencies, useful for BOMs) but without specifying it.
For example if you have a Spring Boot project and use that starter :
<dependency>
<groupId>org.zkoss.zkspringboot</groupId>
<artifactId>zkspringboot-starter</artifactId>
<version>${zkspringboot.version}</version>
</dependency>
Then mvn clean package
will give you the following error :
Error: java: cannot access com.example.myproject
And running the app will result in the following error :
java: error reading ….m2repositoryorgzkosszkspringbootzkspringboot-starter2.3.0zkspringboot-starter-2.3.0.jar;
zip END header not found
because it should not perform any packaging.
Adding the pom
packaging type fixes the problem, so that it keeps the artifact simply as a descriptor of dependency versions :
<dependency>
<groupId>org.zkoss.zkspringboot</groupId>
<artifactId>zkspringboot-starter</artifactId>
<version>${zkspringboot.version}</version>
<type>pom</type>
</dependency>
answered Nov 30, 2020 at 9:01
Yann39Yann39
13.9k11 gold badges56 silver badges84 bronze badges
1
Tweak file watching settings did the trick for me.
For Ubuntu/Mac Run these 2 commands.
sudo echo "fs.inotify.max_user_watches = 524288" | sudo tee /etc/sysctl.d/40-idea.conf
sudo sysctl -p --system
answered Dec 8, 2020 at 4:31
Supun WijerathneSupun Wijerathne
11.8k9 gold badges60 silver badges86 bronze badges
I had a similar issue when I used the dependency thymeleaf-extras-springsecurity4
from org.thymeleaf.extras
in a spring boot application.
Updating the dependency to the latest version helped.
answered Nov 4, 2019 at 14:40
malliaridismalliaridis
3691 silver badge12 bronze badges
Answer by Averi Castaneda
As mentioned above, just delete the corrupted cache and restart Intellij.,and after deleting the folder /home/cesarc/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb the problem was solved:,Find centralized, trusted content and collaborate around the technologies you use most.,
Why was the Devil/Satan not chained and kept in darkness like the other fallen angels mentioned in Jude 1:6 and 2 Peter 2:4?
Running gradle in the commandline can help knowing what you should delete. For instance:
$ ./gradlew --version
Could not unzip /home/cesarc/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb/gradle-5.6.2-all.zip to /home/cesarc/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb.
Reason: error in opening zip file
and after deleting the folder /home/cesarc/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb the problem was solved:
$ ./gradlew --version
Downloading https://services.gradle.org/distributions/gradle-5.6.2-all.zip
......
Answer by Lia Hahn
I am unable to compile Java code for an imported Eclipse project on IntelliJ build 182.4505.22 on Java 9 and 10. The following error is displayed when compiling the module, or any individual file:,As mentioned above, just delete the corrupted cache and restart Intellij.,Updating the dependency to the latest version helped. ,I Had Similar issue in my mac.I just deleted .m2 repository and did maven clean install again worked.
I am unable to compile Java code for an imported Eclipse project on IntelliJ build 182.4505.22 on Java 9 and 10. The following error is displayed when compiling the module, or any individual file:
Error:(1, 1) java: cannot access edu.wit.cs.comp2000
zip END header not found
Answer by Aspyn Sims
Example 1: Cause: zip END header not found
$ ./gradlew --version
Downloading https://services.gradle.org/distributions/gradle-5.6.2-all.zip
......
Example 2: Cause: zip END header not found
$ ./gradlew --version
Could not unzip /home/cesarc/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb/gradle-5.6.2-all.zip to /home/cesarc/.gradle/wrapper/dists/gradle-5.6.2-all/9st6wgf78h16so49nn74lgtbb.
Reason: error in opening zip file
Answer by Harley Harrington
$ ./gradlew --version
Downloading https://services.gradle.org/distributions/gradle-5.6.2-all.zip
......
Answer by Jakob Boone
Environment:
java -version
openjdk version «11.0.9» 2020-10-20
OpenJDK Runtime Environment GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06)
OpenJDK 64-Bit Server VM GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06, mixed mode, sharing),I’m using the same Graalvm version too:
openjdk version «11.0.9» 2020-10-20
OpenJDK Runtime Environment GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06)
OpenJDK 64-Bit Server VM GraalVM CE 20.3.0 (build 11.0.9+10-jvmci-20.3-b06, mixed mode, sharing)
OS: Windows 10,native-image —version
GraalVM Version 20.3.0 (Java Version 11.0.9+10-jvmci-20.3-b06),I have seen that this will be probably a graalvm Windows error, but I would like to know if someone could solve this error in Windows environment, if it’s possible.
Error: Invalid or corrupt jarfile /home/dzou/.gradle/caches/modules-2/files-2.1/org.graalvm.nativeimage/svm-hosted-native-linux-amd64/20.3.0/1eb9f7ea955f02c49cc5f3fa722f388cb15e8dd5/svm-hosted-native-linux-amd64-20.3.0.tar.gz
Caused by: java.util.zip.ZipException: zip END header not found
:nativeImage (Thread[Execution worker for ':',5,main]) completed. Took 0.152 secs.
1 Problem description
Someday useGradle
When building the project,IDEA
The error is as follows:
2 reasons
The reason is downloadedGradle
, Which iszip
The compressed package is incomplete, making it unusableGradle
Construct.
3 Solution
3.1 Delete the local cache and download again
First openIDEA
SettingGradle
,turn upGradle user home
:
For example, the author is~/.gradle
, Open thewrapper/dists
, You can see the cachedGradle
:
Delete the corresponding versionGradle
Yes,IDEA
It will re-download automatically.
3.2 Set a specific versionGradle
If clearing the cache fails to download again, you can set a specific versionGradle
, Download firstGradleGo to the local and download the latest versionxxx-all.zip
To:
Modify the project folder after downloadinggradle/wrapper/gradle-wrapper.properties
,referenceHeremodifydistributionUrl
Is the local path:
defaultGradle
The configuration is as follows:
Generally modifydistributionUrl
Then, if you please check the error report and modify the settings.
Environment
React Native Environment Info:
System:
OS: Windows 10
CPU: x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
Memory: 1.08 GB / 3.89 GB
Binaries:
npm: 6.2.0 — C:Program Filesnodejsnpm.CMD
IDEs:
Android Studio: Version 3.1.0.0 AI-173.4907809
Description
when executing the react-native run-android, the following error occurs:
Scanning folders for symlinks in /Users/Vamsi/AppData/Roaming/npm/node_modules (17ms)
JS server already running.
Building and installing the app on the device (cd android && ./gradlew installDebug)…
Unzipping /Users/Vamsi/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv/gradle-2.14.1-all.zip to /Users/Vamsi/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv
Exception in thread «main» java.util.zip.ZipException: zip END header not found
at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1252)
at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1153)
at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1160)
at java.base/java.util.zip.ZipFile$Source.(ZipFile.java:997)
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:960)
at java.base/java.util.zip.ZipFile.(ZipFile.java:216)
at java.base/java.util.zip.ZipFile.(ZipFile.java:148)
at java.base/java.util.zip.ZipFile.(ZipFile.java:162)
at org.gradle.wrapper.Install.unzip(Install.java:159)
at org.gradle.wrapper.Install.access$500(Install.java:26)
at org.gradle.wrapper.Install$1.call(Install.java:69)
at org.gradle.wrapper.Install$1.call(Install.java:46)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:46)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/android-setup.html
Reproducible Demo
react-native run android
having the same issue can anyone help me out with this issue?
I am closing this issue because it does not appear to have been verified on the latest release, and there has been no followup in a while.
If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here.
Solution:
Go to /Users/{USER_NAME}/.gradle
, delete all folders and files in this folder and run again
Could not unzip C:Usershome.gradlewrapperdistsgradle-5.4.1-all3221gyojl5jsh0helicew7rwxgradle-5.4.1-all.zip to C:Usershome.gradlewrapperdistsgradle-5.4.1-all3221gyojl5jsh0helicew7rwx.
Reason: zip END header not found
Exception in thread «main» java.util.zip.ZipException: zip END header not found
at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1470)
at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1371)
at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1378)
at java.base/java.util.zip.ZipFile$Source.(ZipFile.java:1209)
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1172)
at java.base/java.util.zip.ZipFile$CleanableResource.(ZipFile.java:719)
at java.base/java.util.zip.ZipFile.(ZipFile.java:239)
at java.base/java.util.zip.ZipFile.(ZipFile.java:169)
at java.base/java.util.zip.ZipFile.(ZipFile.java:183)
at org.gradle.wrapper.Install.unzip(Install.java:219)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:75)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with —verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
Exception in thread «main» java.util.zip.ZipException: zip END header not found
at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1470)
at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1371)
at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1378)
at java.base/java.util.zip.ZipFile$Source.(ZipFile.java:1209)
at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1172)
at java.base/java.util.zip.ZipFile$CleanableResource.(ZipFile.java:719)
at java.base/java.util.zip.ZipFile.(ZipFile.java:239)
at java.base/java.util.zip.ZipFile.(ZipFile.java:169)
at java.base/java.util.zip.ZipFile.(ZipFile.java:183)
at org.gradle.wrapper.Install.unzip(Install.java:219)
at org.gradle.wrapper.Install.access$600(Install.java:27)
at org.gradle.wrapper.Install$1.call(Install.java:75)
at org.gradle.wrapper.Install$1.call(Install.java:48)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:69)
at org.gradle.wrapper.Install.createDist(Install.java:48)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)
facebook
locked as resolved and limited conversation to collaborators
Jan 1, 2020
The IntelliJ Compilation Error «zip END header not found» is a common issue faced by Java developers while using the IntelliJ IDEA IDE. This error occurs when the compiler is unable to locate the required classes for compiling a project due to missing or corrupt JAR files.
Method 1: Update IntelliJ IDEA
To fix the «zip END header not found» error in IntelliJ IDEA, you can try updating the IDE to the latest version. Here are the steps to do it:
- Open IntelliJ IDEA and go to «Help» in the menu bar.
- Click on «Check for Updates».
- If there is a new version available, click on «Download and Install».
- Wait for the update to complete and restart IntelliJ IDEA.
Updating IntelliJ IDEA can fix various issues, including the «zip END header not found» error. If you still encounter the error after updating, you can try the following solutions:
- Clean the project and rebuild it.
- Invalidate the caches and restart IntelliJ IDEA.
File -> Invalidate Caches / Restart...
- Delete the .idea folder and re-import the project.
- Check if any dependencies are corrupted and re-download them.
./gradlew clean build --refresh-dependencies
By following these steps, you should be able to fix the «zip END header not found» error in IntelliJ IDEA.
Method 2: Invalidate Caches and Restart IntelliJ IDEA
To fix the «zip END header not found» error in IntelliJ IDEA, you can try invalidating the cache and restarting the IDE. Here are the steps to do it:
- Open IntelliJ IDEA.
- Go to «File» > «Invalidate Caches / Restart».
- In the dialog box that appears, select «Invalidate and Restart».
- Wait for IntelliJ IDEA to restart.
After restarting, try to build your project again. If the error persists, you can try the following code example to manually delete the cache:
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.impl.ProjectLifecycleListener;
import com.intellij.openapi.project.impl.ProjectManagerImpl;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.io.DeleteUtil;
import java.io.File;
public class CacheUtil {
public static void clear(Project project) {
ApplicationManager.getApplication().runWriteAction(() -> {
VirtualFile baseDir = project.getBaseDir();
if (baseDir != null) {
File cacheDir = new File(baseDir.getPath(), ".idea");
if (cacheDir.exists() && cacheDir.isDirectory()) {
DeleteUtil.delete(cacheDir);
}
LocalFileSystem.getInstance().refreshIoFiles(new File[]{cacheDir.getParentFile()});
VfsUtilCore.refreshAndFindFileByIoFile(cacheDir.getParentFile(), true);
((ProjectManagerImpl) ProjectManagerImpl.getInstance()).reloadProject(project);
}
});
}
}
This code will clear the cache for the specified project. You can call this method before building your project to ensure that the cache is cleared:
CacheUtil.clear(project);
Note that this method may take some time to complete, depending on the size of your project’s cache.
Method 3: Delete the corrupted JAR file and reimport
To fix the «zip END header not found» error in IntelliJ by deleting the corrupted JAR file and reimporting it, follow these steps:
- Locate the corrupted JAR file in your project directory.
- Delete the corrupted JAR file.
- Reimport the JAR file into your project.
Here’s an example code snippet to delete the corrupted JAR file:
File corruptedJarFile = new File("path/to/corrupted.jar");
if (corruptedJarFile.delete()) {
System.out.println("Corrupted JAR file deleted successfully.");
} else {
System.out.println("Failed to delete corrupted JAR file.");
}
And here’s an example code snippet to reimport the JAR file:
File jarFile = new File("path/to/jar/file.jar");
URLClassLoader classLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
Method addUrlMethod = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
addUrlMethod.setAccessible(true);
addUrlMethod.invoke(classLoader, jarFile.toURI().toURL());
The first line creates a File
object for the JAR file you want to reimport. The second line gets the system class loader as a URLClassLoader
. The third line uses reflection to access the addURL
method of the URLClassLoader
. The fourth line sets the addURL
method to be accessible. The fifth line invokes the addURL
method with the URL of the JAR file you want to reimport.
That’s it! With these steps, you should be able to fix the «zip END header not found» error in IntelliJ by deleting the corrupted JAR file and reimporting it.
Method 4: Re-download the missing JAR file
To fix the IntelliJ Compilation Error «zip END header not found» in Java, you can try re-downloading the missing JAR file. Here are the steps to follow:
-
Identify the missing JAR file causing the error. You can find this information in the error message.
-
Go to the Maven repository or the official website of the library to download the JAR file.
-
Delete the old JAR file from your project’s directory.
-
Add the new JAR file to your project’s directory.
-
Refresh your project in IntelliJ to ensure the new JAR file is recognized.
Here is an example code snippet to download a JAR file using Maven:
<dependency>
<groupId>com.example</groupId>
<artifactId>example-library</artifactId>
<version>1.0.0</version>
</dependency>
And here is an example code snippet to add the JAR file to your project’s directory:
cp example-library-1.0.0.jar /path/to/your/project/directory
Make sure to replace «example-library-1.0.0.jar» with the name of the JAR file you downloaded and «/path/to/your/project/directory» with the path to your project’s directory.
By following these steps, you should be able to fix the «zip END header not found» error in IntelliJ.
Method 5: Check for conflicting JAR files
To fix the IntelliJ Compilation Error «zip END header not found», you can use the «Check for conflicting JAR files» feature in IntelliJ. Here are the steps to do it:
- Open your IntelliJ project and go to the «File» menu.
- Select «Project Structure» from the dropdown menu.
- In the Project Structure dialog, select «Modules» from the left-hand menu.
- Select the module that is giving you the «zip END header not found» error.
- Click on the «Dependencies» tab.
- Look for any conflicting JAR files that are listed in red.
- Click on the conflicting JAR file to select it.
- Click on the «Exclude» button to exclude the conflicting JAR file from your project.
- Click «OK» to save your changes.
Here is an example code snippet that demonstrates how to exclude a conflicting JAR file using the «Check for conflicting JAR files» feature:
<dependency>
<groupId>com.example</groupId>
<artifactId>example-library</artifactId>
<version>1.0</version>
<exclusions>
<exclusion>
<groupId>com.example</groupId>
<artifactId>conflicting-library</artifactId>
</exclusion>
</exclusions>
</dependency>
In this example, we are excluding the «conflicting-library» JAR file from the «example-library» dependency.
By following these steps and excluding any conflicting JAR files, you should be able to fix the «zip END header not found» error in IntelliJ.