
In the example below, Gradle will use JDK 20 to execute the tasks in the build regardless of the JDK version being used to run Gradle. In adle, replace sourceCompatibility JavaVersion.VERSION11 targetCompatibility JavaVersion.VERSION11. This can be easily changed by configuring your toolchain. Important: Dynamically swapping Java, Maven or Gradle versions manually is a.
#Gradle set java version how to
Configuring the Toolchainīy default, Gradle will use the JDK that is being used to run Gradle itself to execute the tasks in the build. This guide walks you through how to fully configure a Java application.

As of the time of this article, the latest Gradle version is 7.6 which supports JDK 19. Be sure that the JDK installed to run Gradle is supported by Gradle. According to the release notes, JDK 17 required. This article assumes that you have multiple JDKs installed on your system: one for running Gradle, and the other for executing the tasks in the build. Hello, I updated to Flamingo today (stable release), AGP 8.0 and Gradle 8.0 and I am receiving the above error.

These tools enable you to easily manage and switch between your local JDKs.

When working with multiple JDKs, using a tool like SDKMan or Jenv (for macOS) is highly recommended. However, that’s not the case, and we will explore in this article how to run Gradle with one JDK version while building and testing with a different JDK version. If you are using Gradle as the build tool for your projects and want to work with the latest JDK releases or early-access builds, you might think you are stuck until Gradle supports those versions of the JDK, which might take a few months.
