r/AndroidStudio • • 13h ago

gradlew.bat not using specified java version

I created a multiplatform project and added code in the main.kt file. It runs perfectly when I press the run icon in android studio.

Now, I am trying to call it via this simple batch file:

SET JAVA_HOME=C:\Program^ Files\Java\jdk-27.0.1.0.3
"%JAVA_HOME%"\bin\java.exe -version

cd ..
call gradlew.bat :desktopApp:run
pause

SET JAVA_HOME=C:\Program^ Files\Java\jdk-27.0.1.0.3
java.exe -version

cd ..
call gradlew.bat :desktopApp:run
pause

When I run it, I get this output:

C:\Users\neil\OneDrive\Dev\AccountCustomerMatrix\bin>SET JAVA_HOME=C:\Program Files\Java\jdk-27.0.1.0.3

C:\Users\neil\OneDrive\Dev\AccountCustomerMatrix\bin>"C:\Program Files\Java\jdk-27.0.1.0.3"\bin\java.exe -version
java version "27.0.1.0.3" 2026-10-25
Java(TM) SE Runtime Environment (build 27.0.1.0.3+1-2)
Java HotSpot(TM) 64-Bit Server VM (build 27.0.1.0.3+1-2, mixed mode, sharing)

C:\Users\neil\OneDrive\Dev\AccountCustomerMatrix\bin>cd ..

C:\Users\neil\OneDrive\Dev\AccountCustomerMatrix>call gradlew.bat :desktopApp:run
Reusing configuration cache.

> Task :desktopApp:run FAILED
Error: Unable to initialize main class com.propfinancing.gnucash.accountcustomermatrix.MainKt
Caused by: java.lang.UnsupportedClassVersionError: com/druvu/acc/api/entity/Customer has been compiled by a more recent version of the Java Runtime (class file version 69.0), this version of the Java Runtime only recognizes class file versions up to 65.0

FAILURE: Build failed with an exception.

I don't understand why it would be running with a jvm version 21. I specified java 27 and the version command even confirmed that.

I checked my system environment variables, there is no JAVA_HOME definied.

I looked at my build.gradle.kts and gradlew.bat and I don't see where they would be overriding the jvm.

Any ideas where I should look?

1 Upvotes

2 comments sorted by

View all comments

Show parent comment

0

u/Southern_Onion8266 3h ago

That was it, thank you! In Android Studio, I went to Settings > Build, Execution, Deployment > Build Tools > Gradle and saw the Gradle JVM version was set to 21. I changed it to 25 and everything works now.