IntelliJ Gradle Plugin: The supplied javaHome seem

2019-01-30 17:28发布

Similar to:
- Intellij 14 the supplied javaHome seems to be invalid
- Android Studio - supplied javaHome is not a valid folder

However, I am trying to use my JAVA_HOME variable which is set to C:\Program Files\Java\jdk1.8.0_40

I do not understand why intellij is looking for the JDK inside of its install directory.

In intellij:

Executing external task 'bootRun'...
The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1\jre\bin\java.exe
External task execution finished 'bootRun'.

C:\>java -version
java version "1.8.0_40"
Java(TM) SE Runtime Environment (build 1.8.0_40-b25)
Java HotSpot(TM) 64-Bit Server VM (build 25.40-b25, mixed mode)

C:>env
...
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_40
...

13条回答
可以哭但决不认输i
2楼-- · 2019-01-30 17:31

On OSX 10.12.x, Intellij v16.3, I had to go into:

  1. ~/Library/Preferences/IntelliJIdea2016.3
  2. Create a file called: idea.jdk
  3. Add the following to it: /Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk (or whatever JDK you have installed

This was a fix I've had to do in v16 of Intellij found on jetbrains site. At one point I had to remove it, on the upgrade to 16.3 I had to add it back. https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under

查看更多
劫难
3楼-- · 2019-01-30 17:33

Try manually setting a JDK from File > Project Structure > Project > Project SDK, Then rebuild.

查看更多
老娘就宠你
4楼-- · 2019-01-30 17:35

IDEA comes in 2 versions: 32bit and 64bit.

Your JAVA_HOME is 64bit version of Java so you have to run 64bit version of the IDEA ...\IntelliJ\IntelliJ IDEA Community Edition 14.1.2\bin\idea64.exe.

Otherwise, you can provide 32bit JDK or tweak the behaviour with IDEA settings https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under

查看更多
乱世女痞
5楼-- · 2019-01-30 17:35

I've solved this issue by putting gradle.properties file in the same dir as build.gradle with exact path to my JDK:

org.gradle.java.home = C:/Dev/JDK

Actually it is not a correct solution, probably it should be fixed in IDE, I see in IDEA logs something like (when I executing gradle task of already imported project):

INFO - s.plugins.gradle.GradleManager - Instructing gradle to use java from C:/Dev/JDK

But when I going to import gradle module to the project I don't see such kind of message, probably IDEA passes link to bundled JRE which is actually not a JDK.

查看更多
戒情不戒烟
6楼-- · 2019-01-30 17:35

in IntelliJ 2018.1, I ran into this problem because my project SDK was set to Kotlin instead of a JDK. So, despite having a Kotlin project, it would only build if the SDK is a JDK.

查看更多
再贱就再见
7楼-- · 2019-01-30 17:36

In my case the answers above didn't work. Here's what work for me: I needed to change Gradle JVM to point to the actual JDK: Image showing IntelliJ Settings window

查看更多
登录 后发表回答