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

五迷三道 提交于 2019-12-01 14:59:22

You should probably try to update your JAVA_HOME in system variables and Java version used in eclipse to be consistent to

JAVA_HOME=/path/to/jdk9

In MacOSX, something like :

JAVA_HOME = /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home/bin

As informed in comments, the default path on Linux would be :

/usr/lib/jvm/java-9-openjdk

From what I can see, it is the Gradle version issue. (Gradle and Java 9 compatibility issue).

You need to upgrade the wrapper to 4.3.1, cli ref:

# upgrade Gradle to 4.3.1 
gradle wrapper --gradle-version 4.3.1 # not ./gradlew

Let me know if that works.

stein korsveien

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

For me the problem was that I used

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_10
    targetCompatibility JavaVersion.VERSION_1_10
}

but the project was configured for Java 1.8. So I changed these to 1_8 and it works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!