Yes, that’s right.
It detects from several standard places that some SDK managers or OS packages use or from the Windows registry.
Even the 11.0.11 it detected is not detected because you installed it, but because you run Gradle with it.
Where the algorithm looks for Java installations is listed in the documentation.
If you installed the AdoptOpenJdk packages from MSI and in the installer chose to set the Oracle registry keys, they would have been detected.
Alternatively you can tell it to look in those paths for JDKs like also documented.
How do I get Gradle to detect available JDKs on Windows? From the documentation there is nothing mentioned of any configuration for Toolchain to work on Windows.
Other that to specify custom toolchain locations org.gradle.java.installations.paths=C:\Program Files\Java\jdk-11,C:\Program Files\Java\jdk-14,C:\Program Files\Java\jdk-15,C:\Program Files\Java\jdk-16
Hm, ok, I had it more detailed in memory.
But as I said, the “standard location” on Windows afair is where it is registered in the registry.
I just installed a fresh windows box yesterday, used the MSI installers and checked the option to write the registry entries, and all are detected by Gradle.
Ok. So then all JDKs I install with MSI will be detected.
I will try that.
I just tried to unpack the JDKs under C:\Users\myuser\.gradle/jdks
Running gradlew.bat -q javaToolchains does not list them, but the build does not fail. The toolchain I have defined in build.gradle for JDK-14 is used.
I installed OpenJDK 11, 14, 15 and 16 using the MSI installers.
Checked to update registry for all of them.
Running Gradle with JDK 11. JDK 11 also has the JAVA_HOME.
Gradle now lists all these as toolchains.
The thing is, I wanted them in the .gradle/jdks directory on Windows.
When building with Docker I mount the .gradle directory, that way the docker image also has access to these toolchains.
Now I would need to install all the JDKs in the Docker image with MSI. Not an easy feat. My current docker image in Windows just unpacks archives, because installing silent MSI in docker build didn’t work.
Well, that’s totally new information you didn’t mention before.
After successfully unpacking to $GRADLE_USER_HOME/jdks create a file called provisioned.ok in the respective directory.
The marker is created after the unpacking is finished and thus ensures that no half-unpacked jdk is used, either because of the unpacking failing or because of currently being in the process of unpacking.