How To Define a Specific Java Home for Gradle¶
By default, Gradle uses the JDK defined in the
JAVA_HOME environment variable or in the
If you want to use a different JDK without changing the default JDK of your system,
you can define the property
org.gradle.java.home in the Gradle Properties.
Gradle Properties can be defined in the following locations, sorted by the highest priority:
- command line, as set using
GRADLE_USER_HOMEdirectory (defaults to
gradle.propertiesin the project directory, then its parent project directory up to the build root directory.
gradle.propertiesin the Gradle installation directory.
If an option is configured in multiple locations, the first one found in any of these locations wins.
Therefore, if you want all your Gradle project to use a different JDK than the system default JDK,
you can add the following property in the file