Tell Gradle to use specific JDK version? [duplicate]
Two ways
- In
gradle.properties
in the.gradle
directory in yourHOME_DIRECTORY
setorg.gradle.java.home=/path_to_jdk_directory
or:
-
In your
build.gradle
compileJava.options.fork = true compileJava.options.forkOptions.executable = '/path_to_javac'
If you add JDK_PATH in gradle.properties your build become dependent on on that particular path. Instead Run gradle task with following command line parametemer
gradle build -Dorg.gradle.java.home=/JDK_PATH
This way your build is not dependent on some concrete path.