Importing a Gradle project in IntelliJ using different java jdk version - java

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"

Related

gradle7.3.3 Could not determine java version from '11.0.10'

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.

Could not initialize class org.codehaus.groovy.runtime.InvokeHelper

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.

Issues with running a LibGDX project

I downloaded the libGDX setup jar file, I generated a project and imported it (to eclipse). Once I try to run the project eclipse outputs an error:
Description Resource Path Location Type
Could not create an instance of Tooling API implementation using the specified Gradle distribution 'https://services.gradle.org/distributions/gradle-4.6-bin.zip'.
Could not create service of type FileMetadataAccessor using NativeServices.createFileMetadataAccessor().
Could not determine java version from '11.0.2'.
I have no idea how to solve this problem.
The problem is that you are using Java 11. Try it with Java 8. The HTML module does not compile with a Java version greater then 8.
Gradle 4.6 likely does not support Java 11.
You can either upgrade to a newer version of Gradle or downgrade your JDK version.
I would recommend updating to Gradle 4.10.2 as it is the latest Gradle 4 variant (you can try Gradle 5 however it may introduce some breaking changes)
This can be done by running in the root of your project:
Linux / MacOS:
./gradlew wrapper --gradle-version=4.10.2
Windows:
gradle wrapper --gradle-version=4.10.2

IntelliJ Gradle Could not Determine Java Version

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.

Jmeter with Eclipse

I'm learning how to build Jmeter with Eclipse.
I followed some online steps and downloaded Jmeter binary and source files, unzipped them into the same directory, created a java project in eclipse and used ant build but when i build i got the following error
\workspace\apache-jmeter-2.11\build.xml:801: Class not found: javac1.8
I'm using JRE8, JDK1.8 and ant 1.9.4.
Saw some similar post with answers saying that this is an issue with ant version < 1.9 but i'm already using ant 1.9.4.
Help please.
As that is a problem encountered with versions of Ant which are not compliant with Java 8, I suggest you check your Ant configuration. Go to your Eclipse settings and check it. Then, check your project settings, maybe you have project-specific settings which override your general Eclipse settings.
In the settings, you can choose which Ant install you want to use. By default, Eclipse is using it's own, which is probably not the last available. If you have installed Ant 1.9.4, you should select "External installation" or something, with the version of Ant you installed.
More infos here: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-ant-version.htm

Categories

Resources