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
I had a similar issue with eclipse, I had to set JAVA_HOME in Properties -> Gradle.
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
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.
I faced the issue because in IntelliJ Idea in the Settings > Build Tools > Gradle In "Gradle" section, Gradlje JVM used an incorrect Java version. So I specify to use JAVA_HOME and it fixes the issue.
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.
What I did to fix this problem was I did this on my imported project build.gradle on compileJava section I changed sourceCompatibility and targetCompatibility into 8. It works for me. this happen when you import project from other resource, which is build in different version.