3

Gradle say Java home is different in macOS Catalina. enter image description here

But /System/Volumes/Data/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home is /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home

The newly created daemon process has a different context than expected.
Java home is different.
Expecting: '/System/Volumes/Data/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home' but was: '/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home'.
Please configure the JDK to match the expected one.

I have done the following, but it does not solve the problem.

  1. Add gradle.properties in ~/.gradle/gradle.properties
org.gradle.java.home=/System/Volumes/Data/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
  1. Set IDEA Project Gradle JVM enter image description here

  2. Set JAVA Home for project structure enter image description here

  3. Export JAVA_HOME in .zshrc

Export JAVA_HOME=/System/Volumes/Data/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home

Environment

------------------------------------------------------------
Gradle 5.5.1
------------------------------------------------------------

Build time:   2019-07-10 20:38:12 UTC
Revision:     3245f748c7061472da4dc184991919810f7935a5

Kotlin:       1.3.31
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.14 compiled on March 12 2019
JVM:          12.0.2 (Oracle Corporation 12.0.2+10)
OS:           Mac OS X 10.15 x86_64

TBXark VFanx
  • 206
  • 2
  • 10
  • Seems that Gradle tooling API (which IDE uses) does not handle such kind of links correctly. Reported the https://youtrack.jetbrains.com/issue/IDEA-187229 for investigation and tracking of it in IDE's side. – Andrey Jul 23 '19 at 09:14
  • @Andrey https://github.com/gradle/gradle/issues/10041 But I also get the same error with the command line. macOS is really a bugOS. I have given up on gradle and compiled successfully with maven. – TBXark VFanx Jul 24 '19 at 01:20
  • you should not set JAVA_HOME nowadays, see also https://stackoverflow.com/questions/1117398/java-home-directory-in-linux – soloturn Apr 21 '20 at 04:27

2 Answers2

0

you should not set JAVA_HOME nowadays, java knows where it is installed. see here: JAVA_HOME directory in Linux

soloturn
  • 958
  • 9
  • 8
0

This worked for me

  1. Open Module Settings
  2. Under Build, Tools and Deployment, Go to Gradle Settings
  3. Change the Gradle JVM dropdown to the expected JVM from the error log
  4. Apply an Rebuild