0

I want to use JDK11 in Gradle for compiling my project without modifying JDK_HOME, which points to JDK10. I'm using JDK10 for most projects, but testing an upgrade to JDK11 in Gradle.

JAVA_HOME=C:\Program Files\Java\jdk-10.0.2 

In /.gradle/gradle.properties I set the following property:

org.gradle.java.home=C:/Program Files/Java/jdk-11.0.3

when I run the command: gradle properties, I see the following line:

org.gradle.java.home: C:/Program Files/Java/jdk-11.0.3

but when I run the command: gradle -version, I see this, showing JVM is version 10:

------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------

Build time:   2019-04-26 08:14:42 UTC
Revision:     261d171646b36a6a28d5a19a69676cd098a4c19d

Kotlin:       1.3.21
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          10.0.2 ("Oracle Corporation" 10.0.2+13)
OS:           Windows 10 10.0 amd64

Despite is saying JDK10 above, is it still compiling in JDK11 and JVM only means the Java version used to run the Gradle Daemon?

udeleng
  • 866
  • 2
  • 14
  • 20
  • Does this answer your question? [How do I tell Gradle to use specific JDK version?](https://stackoverflow.com/questions/18487406/how-do-i-tell-gradle-to-use-specific-jdk-version) – Raman Mar 02 '21 at 16:51

1 Answers1

1

The version reported by gradle -version is the one of the client VM executing that command.

Normally, Gradle will otherwise use a daemon process to execute your build. That process will respect the org.gradle.java.home setting.

Note that you can also have a finer control on which Java executable is used for the different tasks in Gradle. See the documentation for details.

Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43
  • 1
    This answer is out of date. See https://stackoverflow.com/a/66443594/430128 for an answer with Gradle's Java Toolchain support. – Raman Mar 02 '21 at 19:53