Gradle 9.0.0
Update: Gradle 9.0.0 requires Java 17+ to run, uses Kotlin 2 and Groovy 4, and adopts Semantic Versioning (SemVer) with version numbers in the format MAJOR.MINOR.PATCH.
Requiring Java 17+ is a breaking change from previous versions, which supported Java 8+.
See Release Notes, What’s New, and Upgrading to Gradle 9.0.0.
Documentation
See Compatibility Matrix in the fine manual.

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 Gradle 8.7 cannot run itself on Java 22. Gradle releases tend to lag behind Java releases because Gradle depends on Groovy and Kotlin which must both be updated first. The workaround is to install both Java 21 and Java 22. Run Gradle 8.7 on Java 21, while letting Gradle manage your Java 22 project. To do this in IntelliJ, see my Answer.
See related Question, Gradle 8.7 cannot find installed JDK 22 in IntelliJ.
Tip: For managing installations of Java versions on Unix-oriented platforms (macOS, Linux, etc.), I like to use SDKMAN!.
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.
java { toolchain { languageVersion = 21 } }