Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'

Trying to deploy my app to heroku, but it keeps failing with the error: Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'

I have my JAVA_HOME,JAVA_PATH,and so on.. set up, i have an image of all of them here, i think they are correct. If i check java -version, and javac -version, they both show java 11.

I also tried putting to the root folder a system.properties.txt file and also instead of .txt a .gradle file with java.runtime.version=11 inside it.

Also i have this in my build.gradle:

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11

But it keeps installing jdk8 at the start of the deploy(git push heroku master) like this:

Gradle app detected
remote: -----> Spring Boot detected
remote: -----> Installing JDK 1.8... done
remote: -----> Building Gradle app...
remote: -----> executing ./gradlew build -x test
remote:        Downloading https://services.gradle.org/distributions/gradle-5.4.1-all.zip

here are the Images of the deploy failing and the environmental variables that are set up.

enter image description here enter image description here

I have been with this problem for a week now, i think i tried all, but i would be really greatful if someone could help me with this. Thank you!

like image 260
Daniel Jeney Avatar asked Aug 15 '19 18:08

Daniel Jeney


People also ask

What version of Java does gradle use?

A Java version between 8 and 18 is required to execute Gradle. Java 19 and later versions are not yet supported. Java 6 and 7 can still be used for compilation and forked test execution. Any supported version of Java can be used for compile or test.

How do I change my gradle from org to Java home?

Right click on the deploy or any other task and select "Open Gradle Run Configuration..." Then navigate to "Java Home" and paste your desired java path.

Which Java version is latest?

Java Platform, Standard Edition 18Java SE 18.0. 2.1 is the latest release of Java SE Platform. Oracle strongly recommends that all Java SE users upgrade to this release.


1 Answers

I had the same problem getting a "Java SE 11 using tool chain JDK 8" error. After Googling the problem, I was hinted toward the JAVA_HOME settings.

I use sdkman to manage my Java and Kotlin versions current version settings so after checking the current Java version configured in sdkman, I realized it was pointing to the GraalVM version 19 which targets Java 8.

So I simply reinstated the current JAVA_HOME to 11 with "sdkman use java 11.0.1-zulu" and everything was working fine.

Softjake

like image 66
softjake Avatar answered Sep 20 '22 14:09

softjake