I'm trying to run a program in Command Prompt, and all goes well until I actually try to use the java command on the compiled class and get the following error:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: Main has been compiled by a more
recent version of the Java Runtime (class file version 57.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 have made sure that my Java Runtime and JDK are up to date. My JDK version is 13.0.2 and java -version output is
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) Client VM (build 25.241-b07, mixed mode)
I have looked around Stack Overflow but everyone seems to just have the wrong version, so does anyone know what went wrong here?
It seems to me all regular. I think you Have compiled with 13 but you try to execute with 8 (as i see in your Java 1.8 output. Your default Java is 8, so if you want to use 13 try to specify a complete path for Java command