Search code examples
javacommand

How to fix "A JNI error has occurred, please check your installation."


I have written a Java program on Eclipse and I'm able to run the program. But when I transfer it to Notepad++ and run it via command prompt. It gave me an ERROR message. Any idea on how to solve it?

I have attach an image of the error.

"Error Message"

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

Solution

  • The error message tells you that the class version is different. In other words, the Java compiler you used in Eclipse is newer than the Java runtime you use in the command prompt. You should check which Java version you want then use only this version. To change the version you use in the command prompt you must change the path environment variable to contain the path to the desired version. In Eclipse you can select the used version in the settings.