I'm using IntelliJ to work with a Gradle project. I noticed that whenever I try to refresh the Gradle project (or when trying to import/re-import a project as a Gradle project) I get the following error:
Error: Could not determine the Java version
$JAVA_HOME is set, the SDK is set to Java 8 (and gradle -version confirms it is also is set to Java 8), and the project builds fine from the command line. Restarting IntelliJ also does nothing. I also deleted the project specific and global .gradle folders, which did not resolve the issue.
I am running IntelliJ 14.1.4 on Ubuntu 15.04 and Gradle 2.5.
EDIT: Tried it on a different machine (also Ubuntu 15.04, Oracle Java 8) running IntelliJ 14.1.1 and it worked correctly.
I had this problem too. It seems it was linked to the project being setup with a rather old gradle build. Changing distributionUrl to a new distribution in /gradle//wrapper/gradle-wrapper.properties solved it
You should try to switch Idea boot jdk. It works for me.
Related
I am trying be build a java application using "gradlew build". I have installed gradle 7.3.3
and I have java 11.0.10.
From other answers I understand that gradle is compatible with older version but here I have java 11 and latest gradle still I am getting this error.
I also tried following gradle wrapper --gradle-version 7.3.3 but it is giving me following error:
Can anyone suggest what I am missing or should differently.
EDIT: (Content of gradle.wrapper.propertiese file)
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://server_path/gradle/4.6/gradle-4.6-bin.zip
Thanks
After doing some research I found the resolution, posting so that it might help someone else.
NOTE: the gradle you installed on your machine and the gradle used by the project you are trying to build might be different. If you are in bad luck then they might be incompatible based on java version you have on your system.
I had gradle 7.3.3 on my system and the project was using gradle 4.6. The gradle used by project is not compatible with java 11. So, to be on safe side I downgraded both Gradle (to v 4.6) and java (to 1.8) and it worked.
You might not required to downgrade the gradle version on your local machine. I will try that as well and update this answer.
EDIT: It worked with Gradle 7.3.3, java 1.8 and the project using Gradle 4.6.
Spring Boot Project
I'm using gradle 5.2.1 I can't change the version because I'm working on someone else's code. When I build the project in IntelliJ I get the following error:
* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokeHelper
I'm using IntelliJ terminal in my code folder with command ./gradlew clean build install.
when I check ./gradle -version it shows JVM: 16.0.2
I feel the problem is with my jdk version.
As per compatibility matrix , only gradle versions of 7 are supporting java 16.
May be you can use older version of jdk which is supporting your current gradle.
I am getting the following error when running mvn clean test:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/maven/plugin/MojoExecutionException
It's not happening on my development team they say they are running the command just fine.
I've checked the JAVA_HOME and JRE_HOME environments, both fine.
I'm using maven version 3.6.3 and Java version 1.8.0_144
Not sure what to do at this point. This project was installed using IntelliJ git clone
IntelliJ could use a bundled maven version, which could be different from the system/user one. Have you already checked settings of the IDE?
The problem could be related to different option, maybe a log could help more. Be sure that all the dependencies and plugins are downloaded without any problems. In the past I had same issue and it was related to the proxy settings for the download.
Something was wrong with the maven donwload. I remapped the environment settings to use the intellij maven and everything worked great.
I tried to import a gradle project in IntelliJ and I'm getting the following error :
Error:Could not determine java version from '9.0.4'.
As said is the gradle project in java 1.8 ( exactly 1.8.0_152) and the version on my Linux is 9.0.4.
I think I should downgrade the version from 9.0.4 to this 1.8.0_152 but I don't know how to do it.
Can I fix the problem without downgrading the Java version ?
This is a well known bug! Here you can find the issue documentation with a possible solution on github: #16536
Edit the file /android/gradle/wrapper/gradle-wrapper.properties and update the last line with:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3-rc-2-all.zip
Alternate I found this intellij specific solution, solved by pointing intellij at a location of a custom gradle install:
"File > Settings... > Build, Execution, Deployment > Gradle > Use local gradle distribution"
PLEASE NOTE: THIS IS NOT A DUPLICATE. I want Gradle's IDEA plugin to correctly configure my IntelliJ IDEA CE project for me. I am not interested in any solution that involves manually tuning IntelliJ to find my JDK. This is a Gradle IDEA plugin feature that can and should work.
If you can find another question that involves correctly getting the Gradle IDEA plugin to configure IntelliJ (running on a Mac) so that it can find JDK 8+, then please by all means, mark this as a dupe and provide a link to that question. Otherwise, do not vote this as a dupe (it's not!).
Mac 10.9.5 here. Java 8 is my default JRE/JDK, and I just installed Groovy 2.4.6 and Gradle 2.13 via sdkman. I then installed IntelliJ IDEA CE.
On my terminal, I created a test-proj directory, and then inside that directory I issued the following Gradle command:
gradle init --type groovy-library
Gradle executed successfully, giving me a Groovy project skeleton. I then edited the generated build.gradle to contain the IDEA plugin:
apply plugin: 'idea'
And then I ran:
gradle wrapper
./gradlew clean idea
This generated the Gradle Wrapper for me, and I then used the IDEA plugin to generate IntelliJ project files for me. I then opened my brand-spanking-new IntelliJ IDE and went to Open my test-proj.
The project opened and everything appeared to be OK. But then I started coding and noticed that JRE classes such as String were not showing up as resolvable. So I went to File >> Project Structure and see this:
So it appears that IntelliJ can't find my default Java 8 JDK. I know the OS can find both the JRE and the JDK, based on the console ouput of java -version and javac -version. But something, between sdkman, Gradle or IntelliJ is preventing the IDE from finding Java. Any ideas?
I had the same problem, although i got it running by removing the .idea folder and reimporting the project by pointing to my build.gradle file. In the import dialog i selected the .ipr structure instead of using the idea "folder based structure" (default)
When executing gradle idea it will then generate an .ipr file in your project root configuring your project.
In my case the jdk was set properly and my modules were initialized correctly.
The reason behind using the .ipr files is, that the gradle idea plugin can't work with the directory based structure. See also:
directory based idea project with gradle
https://issues.gradle.org/browse/GRADLE-1041 (open for 6 years now)
Since i figured this out today i'm not sure how good this is working. Or what are the differences between directory based and .ipr based (.ipr based seems older?).