Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

  • I'm building ghidra according to the installation guide. Everything goes fine Until I get here.
  • Once I call $ gradle buildGhidra I get the following error:
> Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'

This seems weird because I do have java 11:

$ java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)

What am I missing?

like image 273
OrenIshShalom Avatar asked Oct 01 '20 10:10

OrenIshShalom


4 Answers

I got this problem when trying to build using gradle through Intellij.

In my case I had two JDK's JDK1.8 and JDK 11 installed and configured in Intellij. For Gradle it was taking JDK1.8 as default JVM. I solved the issue using below steps :

  1. Open Intellij
  2. Go to Preferences
  3. Go to "Build, Execution, Deployment" -> "Build Tools" -> Gradle
  4. Search for "Gradle JVM". Change it to desired JVM
  5. Try to rebuild the app
like image 80
Shirishkumar Bari Avatar answered Nov 18 '22 21:11

Shirishkumar Bari


Gradle uses the java distribution defined in your JAVA_HOME environment variable - it does not look at the java executable in your path. So make sure this variable points to a valid JDK 11 path. You can verify if it is set up correctly by running gradle --version, e.g.

$ echo %JAVA_HOME%
C:\Work\JDKs\jdk-11.0.8+10


$ gradle --version

------------------------------------------------------------
Gradle 6.6
------------------------------------------------------------

Build time:   2020-08-10 22:06:19 UTC
Revision:     d119144684a0c301aea027b79857815659e431b9

Kotlin:       1.3.72
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:          11.0.8 (AdoptOpenJDK 11.0.8+10)
OS:           Windows 10 10.0 amd64

(Notice the JVM part above.)

like image 23
Bjørn Vester Avatar answered Nov 18 '22 21:11

Bjørn Vester


Are you using an IDE? Make sure that in your Gradle settings, Gradle is using the same java version as your project, this can be easily configured in Intellij https://www.jetbrains.com/help/idea/gradle-jvm-selection.html#jdk_existing_project

like image 2
Stan van der Bend Avatar answered Nov 18 '22 21:11

Stan van der Bend


  • It turns out that gradle was after all the one to blame.
  • Probably similar to this post, I upgraded to gradle-6.7.
  • Then, calling gradle-6.7 --version, without any JAVA_HOME change whatsoever, I got:

------------------------------------------------------------
Gradle 6.7-rc-3
------------------------------------------------------------

Build time:   2020-09-30 19:16:51 UTC
Revision:     836e96a80625c9c48b612e662e3b13bd2e2f4c3b

Kotlin:       1.3.72
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM:          11.0.8 (Ubuntu 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OS:           Linux 5.4.0-48-generic amd64

Which probably "proves" gradle is indeed the one to blame

like image 1
OrenIshShalom Avatar answered Nov 18 '22 23:11

OrenIshShalom