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

后端 未结 10 890
傲寒
傲寒 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: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
    }
    

提交回复
热议问题