javagradlejava-21

Starting from which version does Gradle support Java 21?


When trying to configure the project using Java 21 I'm getting the error:

Unsupported Java. Your build is currently configured to use Java 21 and Gradle 8.3.

Unfortunately, there is no information in official documentation for now: https://docs.gradle.org/current/userguide/compatibility.html

A Java version between 8 and 20 is required to execute Gradle. Java 21 and later versions are not yet supported.

Starting from which version does Gradle support Java 21?


Solution

  • See Compatibility Matrix in the fine manual.

    enter image description here

    Java 22, Gradle 8.7

    Gradle 8.7 supports Java 22 for compiling, testing, and running JVM-based projects. See Gradle Release Notes and Gradle User Manual.

    But Groovy does not yet support Java 22. Therefore Gradle itself cannot run on Java 22. The workaround is to install both Java 21 and Java 22. Run Gradle on Java 21, while letting Gradle manage your Java 22 project. To do this in IntelliJ, see my Answer.

    On its eventual release, Gradle 8.8 will fully support Java 22.

    See related Question, Gradle 8.7 cannot find installed JDK 22 in IntelliJ.

    Java 21, Gradle 8.5

    For full Java 21 support, you can use Gradle 8.5. The release notes say:

    With this release, Gradle now fully supports compiling, testing and running on Java 21.


    If migrating from older Gradle, see What's new in Gradle 8.0.