Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ/Gradle Could not determine java version from '11.0.1'

I'm running a Linux Ubuntu 18 OS. Installed jdk in a custom local directory.

Normally, IntelliJ recommends that you use the default gradle wrapper. But in my case, I want to be able to change the Gradle Version on the fly whenever it's due for an update. If you use IntelliJ with Gradle, and you bump into the following error:

Could not determine java version from '11.0.1'
like image 563
S34N Avatar asked Feb 03 '19 20:02

S34N


People also ask

Is Gradle compatible with java 11?

The minimum version of Gradle that supports Java 11 is 5.0 . You would need to upgrade to version 7.0 or above for Android.

Could not determine java version from 11.0 2 Intellij?

To Solve Could not determine java version from '11.0. 2' Error You need to upgrade wrapper using this command and just make sure Just Use gradle and not gradlew . gradle wrapper –gradle-version 5.1.

Could not determine java version from 17.0 1 gradlew?

You need to downgrade you java to work with gradle . UPDATED: As gradle version 7.3 released at 5th Nov 2021 , It will now provide support to Java 17. So you either upgrade to 7.3 gradle version or downgrade your java version .


2 Answers

If you use IntelliJ

Checks:

  1. Navigate to:

    File >> Settings >> Build, Execution, Deployment >> Build Tools >> Gradle.

    Alongside Gradle JVM: make sure you select the correct version of Java. Gradle JVM

  2. Navigate to: Right-Click 'Project Root Directory' & Select Open Module Settings. Project Structure windows shows-up. Make sure your JDK home path is added to the Platform Settings >> SDKs : JDK home path Project Structure >> Platform Settings >> SDKs : JDK home path

  3. Still, on the same window Project Structure, select correct SDK relevant to your project under

    Project Settings >> Modules : Module SDK Module SDK

  4. Fix/Solution: Nvavigate to & open: gradle/wrapper/gradle-wrapper.properties & update the distributionUrl version to the latest version. In my case (at the time of this post), my older version was:

    distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip

    And my latest version is:

    distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-bin.zip

    As shown below:

    distributionUrl Version Update

  5. In your build.gradle file make sure you set:

    sourceCompatibility = 11

like image 114
S34N Avatar answered Oct 09 '22 10:10

S34N


If you are using the latest version of intellijIdea.

In my case, 2019.1 -version

Delete the directory idea's jdk

then RESTART idea.

for detail see this pic

enter image description here

Hope this is working for you !

In chinese:

(If you can't read chinese,you needn't to read this.All you need to know have typed above already)

如果你是用最新版本的intellijidea.由于intellijidea默认安装了11的java。而且就算你输入java -verison,告诉你是java8,在ide里面也配置了java 8 idea还是告诉你这个错误。

只有通过删除idea自己下载java11版本,可以解决这个问题。直接删除应用包下的jdk文件夹,重启idea就可以。如下图。

like image 10
linjiejun Avatar answered Oct 09 '22 09:10

linjiejun