This message was deleted.
# community-support
s
This message was deleted.
c
perhaps running in a JDK older than Java 11? It’s recommended to use the Java toolchain feature in Gradle to separate the JDK/JVM running Gradle from what is needed to compile the code.
a
where do I find this toolchain?
a
what im confused with is that my build is successful but its not compiling
c
the error above shows the build failing to compile. Please elaborate on the specific issue.
a
its my first time using java so am not sure what the error exactly is, whenever I run the application it just says
Copy code
Execution failed for task ':api:compileJava'.
> invalid source release: 11

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
c
that’s a build failure. add something like this to build.gradle:
Copy code
java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(11)
    }
}
a
build was successful
👍 1
but another error came up
Copy code
Error: A JNI error has occurred, please check your installation and try again
class has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)

Process finished with exit code 1
c
you have an older version of Java installed on your machine. Install Java 11+.
a
i installed both java 8 and 11
c
alternately, explicitly choose Java 11 when running the application.
a
i think it just worked
👍 1