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

后端 未结 10 846
傲寒
傲寒 2020-12-11 14:39

I want to use java9 on my gradle project inside eclipse oxygen. When I run:

Run as> Gradle Test on  GreeterTest.java

with the followin

相关标签:
10条回答
  • 2020-12-11 15:19

    in Eclipse make sure you have proper settings on Gradle build configuration.

    0 讨论(0)
  • 2020-12-11 15:21

    I faced the same error with different JDK version, so i used the following code which works fine.

    compileJava {
        options.fork = true
        options.forkOptions.javaHome = file('/Library/Java/JavaVirtualMachines/jdk-11.0.5.jdk/Contents/Home')
        targetCompatibility = 11
        sourceCompatibility = 11
    }
    
    0 讨论(0)
  • 2020-12-11 15:21

    Additionally to the other ways you tried:

    Gradle has a default JVM set in your %userprofile%/.gradle/gradle.properties. This is in the folder "C:\Users\j.gradle\gradle.properties" for me:

    org.gradle.java.home=C:/Program Files/AdoptOpenJDK/jdk-11.0.7.10-hotspot
    

    That's where you should also put your newer JVM to make sure gradle can compile newer projects.

    0 讨论(0)
  • 2020-12-11 15:25

    I changed the java_home and upgraded Gradle. Now it is working.

    0 讨论(0)
提交回复
热议问题