Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle 7 & Java 11: No compatible toolchains found for request filter

After upgrading to from Gradle 6.7.1 to Gradle 7.4, the following error occurs:


FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':example-project:compileJava'.
> Failed to query the value of extension 'example-extension' property 'enabled'.
   > Failed to calculate the value of task ':example-project:compileJava' property 'javaCompiler'.
      > No compatible toolchains found for request filter: {languageVersion=11, vendor=any, implementation=vendor-specific} (auto-detect true, auto-download false)
like image 582
Toldry Avatar asked Dec 17 '25 18:12

Toldry


1 Answers

Solution:

Add this to build.gradle:

java {
    toolchain {
        implementation = JvmImplementation.J9
    }
}

Explanation

It turned out that the JDK I used was implemented with J9.

At the time of writing, Gradle ignores JDK implemented with J9 unless explicitly set to use it.

This appears to be a bug:

https://github.com/gradle/gradle/issues/16897#issuecomment-823272229

To check whether your JDK is implemented in J9 or not, run

path/to/your/jdk/bin/java -version

The output will look something like this:

openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.24.0, JRE 11 Linux amd64-64-Bit 20210120_821 (JIT enabled, AOT enabled)
OpenJ9   - 345e1b09e
OMR      - 741e94ea8
JCL      - 0a86953833 based on jdk-11.0.10+9)
like image 69
Toldry Avatar answered Dec 19 '25 12:12

Toldry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!