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
in Eclipse make sure you have proper settings on Gradle build configuration.
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
}
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.
I changed the java_home
and upgraded Gradle. Now it is working.