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 displa
I Had Similar issue in my mac.I just deleted .m2 repository and did maven clean install again worked.
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:
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-all.zip
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
......
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
.
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 ...\.m2\repository\org\zkoss\zkspringboot\zkspringboot-starter\2.3.0\zkspringboot-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>
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