“Error: A JNI error has occurred…” – How to fix this Java Error!

“Error: A JNI error has occurred…” – How to fix this Java Error! Thumbnail
Published on 2. February 2020Last updated on 8. June 2020

You encountered this error message? Don’t panic! You have solved the problem with a simple and fast hand trick. And here you can learn how to do it.

Advertisement

If you have encountered this (or a similar) error message the problem is quickly solved.

“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 56.0), this version of the Java Runtime only recognizes class file versions up to 52.0″

The problem occurs because your JRE (Java Runtime Enviroment) and your JDK (Java Development Kit) are not working together correctly. Usually the problem occurs when you want to call a .jar file by comment line, e.g. with the command java -jar File.jar.

Advertisement

If you want to learn more about Java, check out this book*:

Troubleshoot

To fix the bug, you only need to adjust the environment variables for Java.

To do this, you navigate by typing “env” in your Windows search and open the item “Editing System Environment Variables”. In this window click on “Environment Variables…”.

System Properties - Screenshot

The “Enviroment Variables” window opens. There you select the variable “Path” in the lower window and click on “Edit…”.

Advertisement
Enviroment Variables - Screenshot

There you look for the line where the installation path of your JDK is stored. In this case it is under C:\Program Files\Java\jdk-13.0.1\bin.

If you do not have this entry in your database, you can add it by clicking the “New” button. If you have not yet installed the JDK, you can do so here.

Edit enviroment variable - Screenshot

When you have found the line, click on “Move Up” until the entry is at the top of the list. Done!

Now you have to close and reopen the Windows CMD once and the error should be fixed. I hope this post could solve your problem! 🙂

Related Posts
Join the Conversation

9 Comments

Your email address will not be published. Required fields are marked *