A JNI error has occurred, please check your installation and try again in Eclipse x86 Windows 8.1

I have been having this problem for a while, but now I have figured it out.

It turns out that Java JDK 12 have both the JRE and the JDK inside the bin folder of the Java 12 JDK. (I have always believed that JRE and JDK are different application, but it turns out things have changed)

My problem was that I had Java JDK 12 installed on my computer

At the same time, I had Java 8 (JRE) Installed on my computer.

So my computer is getting confused.

With my command prompt environment setup to run Java and Javac commands:

I typed the follow commands:

java -version  

// this gave me Java 8

After that, I typed:

javac -version

// this gave me Java 12

In other words, my program is getting compiled with Java 12 and I am trying to run with Java 8.

To solve the problem, I uninstalled Java 8 JRE from my computer.

Went back to command prompt to check if "java -version" and "javac -version" is returning the same version number, and yes, it is returning Java 12.

Tried recompiling my program again, and running it. It Worked!!

It worked! Eureka!!


Short answer: Right-click on the class that contains the main method. Click on "Run As". Click on "Java Application". The keyboard shortcut is: Shift+Alt+X J (while holding Shift and Alt, press X; then release Shift and Alt and press J).

Long answer: To be honest, I am not 100% sure why this problem happens. It might be because of using a different jdk. I faced the same error. The solution was easier than I imagined. I was used to running my code using Ctrl + F11. But when I ran it as a java application (the way I described in "short answer"), the problem was resolved. I am not sure if it solves other people's problems as well, but it is worthwhile to try. :)


Running the jar from command line by:

C:\folder\where\jar\stored>java -jar JarName.jar

I got information which made the problem clearer:

main/Main has been compiled by a more recent version of the Java Runtime

enter image description here

In this case jar was compiled with version newer than jre supports.