2

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) or java-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 and java-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
0

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:

Actually Eclipse has its own compiler. You can develop java apps using only the JRE and Eclipse

You can still check/set which JDK version you want to compile to. If you go to Window->Preferences, then click "Java" from the menu on the left and then "Compiler". The first setting allows you to see which JDK version is being complied with. I know this doesn't directly answer your question since JDK isn't actually compiling it, but hopefully it helps!

I just found another way that can solve the problem.

Here's where to add compatibility for it:

image

Add jdk here:

image

And the problem solved.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.