Gradle is trying to use a JDK that has been uninstalled from my system

I’m fairly inexperienced with Gradle and am trying to figure out why a .bat script that was generated by an IDE I’m using keeps trying to use the wrong JDK. The trouble comes when the bat script tries to execute the following command:

"C:\Program Files\Eclipse Adoptium\jdk-11.0.15.10-hotspot/bin/java.exe" "-Xmx64m" "-Xms64m" "-Dorg.gradle.appname=gradlew" -classpath "D:\dev\starling2\game\2022\androidExportTest\android\build\\gradle\wrapper\gradle-wrapper.jar" org.gradle.wrapper.GradleWrapperMain

This causes the following error:


FAILURE: Build failed with an exception.

* What went wrong:
The supplied javaHome seems to be invalid. I cannot find the java executable. Tried location: C:\Program Files\Java\jdk1.8.0_151\bin\java.exe

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

I don’t know why Gradle is looking for Java in C:\Program Files\Java\jdk1.8.0_151\bin\java.exe. I want it to use the OpenJDK 11 installation at C:\Program Files\Eclipse Adoptium\jdk-11.0.15.10-hotspot. The JAVA_HOME is set to point to the OpenJDK 11 installation so I would have expected Gradle to look there. I also tried setting javaHome but that is being ignored too.

1 Like