IntelliJ IDEA Gradle sync: Problem with setting Gradle's Java home to some JDKs

Viewed 2473

I have no problem with:

  1. org.gradle.java.home=C:/Program Files/Java/openjdk1.8.0_202

in my (global) gradle.properties file. Also, no problem without it (with nothing set). But if replace it with one of below configurations (all paths are valid):

  1. org.gradle.java.home=C:/Program Files/Java/openjdk-9.0.4
  2. org.gradle.java.home=C:/Program Files/Java/openjdk-10.0.1
  3. org.gradle.java.home=C:/Program Files/Java/openjdk-11.0.1
  4. org.gradle.java.home=C:\\Program Files\\Java\\oraclejdk-11.0.1

then I will get an error message (same for each) after I save the file and import Gradle changes in IntelliJ IDEA:

Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. For example, an unrecognized jvm option is used. Please refer to the user guide chapter on the daemon at https://docs.gradle.org/5.0/userguide/gradle_daemon.html

Please read the following process output to find out more:

OpenJDK 64-Bit Server VM warning: Ignoring option MaxPermSize; support was removed in 8.0 Error: Could not find or load main class java.base.java.lang=ALL-UNNAMED Caused by: java.lang.ClassNotFoundException: java.base.java.lang=ALL-UNNAMED


The note is the issue is only for IDE Gradle sync. Gradle tasks themselves work correctly (independent from IDE)! Even when I run gradle --status (see here about it) can see everything is OK and daemon is running using JDK 11:

>gradlew --status
   PID STATUS   INFO
 10668 IDLE     5.0

And the path of PID: 10668:

>wmic process where "processId=10668" get Name, ProcessID, ExecutablePath
ExecutablePath                                     Name      ProcessId
C:\Program Files\Java\openjdk-11.0.1\bin\java.exe  java.exe  10668
1 Answers

Finally, I found out the issue was from my IDE settings. It was from SDK Table.

I don't know why correcting them from Project Structure (or Structure for new Projects in Other Settings) couldn't solve the issue. Finally, I imported it (and only it) from a fresh installation.


Note: You don't need a fresh installation really. Just enough to close your IDE, rename its configuration directory and re-open it.

Then IDE starts freshly. This is an opportunity for the test. If OK export pointed setting ... File -> Export Settings ...:

enter image description here

to a file. Then return to your previous state and import the exported file:

enter image description here

If the issue reverted you need to check other settings (other than SDK Table).

Related