0

I have java versions 8 and 11 both installed. When I try to run any .java file in cmd using java command, I get the following message:

      Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: aa 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(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

I've tried installing a newer version of java but nothing has changed.

Aman
  • 1
  • 3

1 Answers1

1

Java 11 should support file format 55 (https://en.wikipedia.org/wiki/Java_class_file#General_layout).
Type java -version on commandline to figure out if you are using the correct installation.
If not change your environemnt variables accordingly.

second
  • 4,069
  • 2
  • 9
  • 24
  • 1
    This is what am getting : java version "1.8.0_212" Java(TM) SE Runtime Environment (build 1.8.0_212-b10) Java HotSpot(TM) 64-Bit Server VM (build 25.212-b10, mixed mode) – Aman May 24 '19 at 00:29
  • 1
    Which is obviously you java 8 installation, use your java 11 installation instead. – second May 24 '19 at 00:35