Reputation: 23
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: 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)
Upvotes: 1
Views: 78042
Reputation: 1
I found that the Java 11 installer defaults the set JAVA_HOME variable and the JavaSoft registration variable to exclude (red cross). Ensure that you select both to add full feature. Complete Java install and then reinstall application. Voila !!!
Upvotes: 0
Reputation: 1
Your answer kind of guided me towards a solution.
The package I was using was named java.example.java
, just changed for com.example.java
and it worked fine.
Upvotes: 0
Reputation: 11
I have faced the same issue but the reason why i was faing that of because I had created a package name called Java and when tried to ran my class getting -a-jni-error-has-occurred
But after going through error logs I found Java package name is prohibited , so I changed my package name and it worked for me
Upvotes: 1
Reputation: 1
I was facing this error due to the folder name which I had named as java. Then as I renamed the folder in which my java programs were kept, it worked fine for me.
Upvotes: 0
Reputation: 1623
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.
Upvotes: 4