22

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'
S34N
  • 7,469
  • 6
  • 34
  • 43
  • 1
    I had similar issue with idea 2019.1, java 12.0.1 and gradle 4.6. I solved the problem by upgrading my gradle to 5.2.1. – vahidreza May 29 '19 at 01:35

8 Answers8

37

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

S34N
  • 7,469
  • 6
  • 34
  • 43
11

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就可以。如下图。

linjiejun
  • 1,468
  • 15
  • 22
  • Well... it seems unbelievable but this actually worked for me. I see this issue here: https://youtrack.jetbrains.com/issue/IDEA-210875, and it seems that deleting this directory somehow reset's intellij's internal JDK. Either way, you have my upvote. Just very strange that this *did* work. – Brooks DuBois May 29 '19 at 19:30
  • @BrooksDuBois Thank you for your precious upvote.May be this is a bug about this version of intellj idea . – linjiejun Jun 20 '19 at 02:09
  • Where would you find this folder in Linux installations? Or do you have to remove another file or folder here? – philburns Mar 23 '23 at 09:51
2

Your gradle is too old for that JDK, upgrade your gradle or downgrade you JDK

deFreitas
  • 4,196
  • 2
  • 33
  • 43
1

I noticed a subtlety in the way you download the IDE from jetbains.com

screenshot of jetbrains.com

You probably want JBR 8 and not JBR 11. Also, make sure your JDK is setup properly with jbsdk bintray downloader plugin.

Brooks DuBois
  • 705
  • 6
  • 16
1

I recently upgraded my Ubantu to 18 from 16. After that I am facing this issue. Problem was during ubantu upgrade java is automatically upgraded to 11 from 8. Hence getting this error. You can simply downgrade jdk using this to solve this. Works for me.

Niket Shah
  • 331
  • 4
  • 4
0

Reintalling Intellij Worked for me. You need to uninstall first before reinstall. While uninstalling, ensure to select option to delete older cache and settings

0

check , maybe you have 2 times gradle in path

Fox user9219598
  • 101
  • 1
  • 4
-1

MODIFY default Boot JDK

  1. OPEN the Action Dialog

enter image description here

  1. SEARCH : switch boot jdk

enter image description here

  1. SELECT the JDK installed by you rather than the intellij default

enter image description here

  1. RESTART intellij idea

  2. IGNORE this popup at right-bottom on IDE enter image description here

HOPE this solution is work for you .

linjiejun
  • 1,468
  • 15
  • 22
  • This works, but better to change the version for Gradle than changing Intellij Boot SDK. See below answer. – Showdawn Aug 15 '19 at 18:28