trying to solve an <issue I have>, I'm launching G...
# community-support
g
trying to solve an issue I have, I'm launching Gradle from the console
./gradlew LineDemo --info
I specifically selected the jvm 21 to run with, in my
build.gradle.kts
with
Copy code
kotlin {
    jvmToolchain(21)
but for some reasons Gradle keeps selecting jdk11, which is also in my
JAVA_HOME
reading the docs Toolchain installations precedence, they state > 1. the installation currently running Gradle is preferred over any other What's that? And why isn't 21 getting chosen?
here some log/info on the jdk selection
Java home is different.
Does
JAVA_HOME
matter in this? I cannot believe I shall change it to match the jdk I actually want
setting
JAVA_HOME
to 21 does work indeed
v
The snippet you shared is about the Java that is used to run the Gradle daemon. The Java version you use to run Gradle has nothing to do with the JVM Toolchain you set. That's the point. Using JVM Toolchain you decouple the Java version you use to run Gradle from the Java version used to compile / run / ... your project's code.
This way you can for example run Gradle using Java 8 while still building Java 21 code.
The "the installation currently running Gradle is preferred over any other" means, that if there are multiple Toolchains that match the requested toolchain and one of them is the Toolchain that is used to run Gradle, then that toolchain will be taken.