Execution failed for task ‘:app:compileJava’ with ./gradlew run

  gradle, gradlew, java, javascript

When I try using "./gradlew run" on my gradle projects, I receive this error:

* What went wrong:
Execution failed for task ':app:compileJava'.
> java.lang.IllegalAccessError: class org.gradle.internal.compiler.java.ClassNameCollector (in unnamed module @0x1fa4cfc5) cannot access class com.sun.tools.javac.code.Symbol$TypeSymbol (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.code to unnamed module @0x1fa4cfc5

I have tried on multiple different projects and it still doesn’t work. I believe it has something to do with gradle expecting a different version of Java, as I am using java 16 and when I check "gradle -v" it says "JVM: 15.0.2". I am not sure how to fix this or if this is even the problem. Any help would be greatly appreciated!

Source: Ask Javascript Questions

LEAVE A COMMENT