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

Solution 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!!

Solution 2:

Solution 1: 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).

Solution 2: As @Professor mentioned, please make sure that java -version and javac -version are the same.

Note: Solution 1 is a quick fix and worked for me and a few other people. It may or may not work for you. I think Solution 2 is the proper way to solve it.

Solution 3:

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.

Solution 4:

Error: A JNI error has occurred, please check your installation and try again in Eclipse

Solution: Check your package name as it may be colliding with the package name in java. Simply change the package name to resolve your issue. :)

Solution 5:

I had similar issues when using 'java' at the beginning of the package name, e.g. java.jem.pc

Check your console output, I was receiving:

Exception in thread "main" java.lang.SecurityException: Prohibited package name: java.jem.pc