Since the update yesterday (yes, the linux update), eclipse denies me to run even the most simple helloworld:
has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Full error text:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: gitplayground/HelloWorld has been compiled by a more recent version of the Java Runtime (class file version 53.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:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)
I tried to update the JRE (and JDK):
- window -> preferences -> java -> installed JREs. I could check:
java-8-openjdk-amd64
(which is currently) orjava-11-openjdk-amd64
. - window -> preferences -> java -> compiler. Compiler compliance level is set to 1.8 (it doesn't know java 11. It does know java 9.)
- window -> preferences -> java -> Installed JREs -> Execution Environment. When clicking on
JavaSE-1.8
in the left list, 2 options appear in the right one:java-8-openjdk-amd64
andjava-1.8-openjdk-amd64
. First one is checked. (But I don't think, that matters, because these should be the same.) - I tried to update eclipse. (No updates available)
So anything is set to Java8. Why does the error still occur?
Btw, some of my projects (the helloworld including) are marked with a red exclamation mark, but the error appears in any project, not in these only.
- I use XUbuntu 18.04 now (before the update anything worked fine)
- I use eclipse Photon
- I use java standard API only
- I use git and the eclipse git plugin
Best Answer
I have encounter the same problem earlier when I downloaded JDK 11 and tried to mess around with java 11, and I tried other comments too but no success. However, go to
Window
->installed JREs
and install most recent version of jdk solves my problem.My guess is that the newer version of java needs to be uninstalled so that the earlier version of java can be used, as I have read from this How do i find out the JDK version Eclipse is using?, combines both answers it seemed like:
I just found another way that can solve the problem.
Here's where to add compatibility for it:
Add jdk here:
And the problem solved.