How to Fix: “A JNI error has occurred, please check your installation and try again”

java-jni-errror

You have encountered this JNI Error error message? Don’t panic! The problem can usually be solved quite quickly – and here you can find out how.

Have you encountered this error message or popup?

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

JNI Error Popup
Java Virtual Machine Launcher: JNI Error Popup

The problem comes from the fact that your JRE (Java Runtime Enviroment), that is your installed Java version and your JDK (Java Development Kit) do not work together correctly.

Now there are several possible solutions for you. Just choose the scenario that applies to you:

JNI Error in Windows CMD

JNI Error in Eclipse

JNI Error when starting a Minecraft Server

JNI Error in Minecraft TLauncher

JNI Error in Windows CMD

The problem can occur if you want to call a .jar file via command line (Windows CMD), e.g. via the command java -jar File.jar or if you have compiled your program with Eclipse before.

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

  • To do this, type “environment variable” in your Windows search and open the “Edit System Environment Variables” item. In this window you click on “Environment variables…”.
System properties - screenshot
System properties – screenshot
  • The “Environment variables” window opens. There you select the variable “Path” in the lower window “System variables” and click on “Edit…”.
Environment variables - screenshot
Environment variables – screenshot
  • There you look for the line where the installation path of your Java JDK is stored. In my case this is under C:\Program Files\Java\jdk-13.0.1\bin.

If you don’t have a Java JDK installed yet, you can download and install the .exe installation file (“x64 Installer”) here.

  • If you do not have this entry, you can add it by clicking the “New” button.
Edit environment variables - screenshot
Edit environment variables – screenshot
  • Select the line with the Java JDK and click on “Move up” until the entry is at the top. Done!
  • Now you have to close and reopen the Windows-CMD once and the error should be fixed.

JNI Error in Eclipse

In Eclipse the problem can also be the JDK and JRE version. But first see if it might be a simpler problem:

Maybe you have named one of your packages identically to a Java internal package (e.g. java). Try to rename your package – this can be the simple solution.

If the problem is not fixed I navigate to your Eclipse workspace and compile your main file manually in the Windows CMD using the following command: javac Main.java. Then you can run the file manually with java Main. If this works, it is probably due to the JDK and JRE versions in Eclipse. Reinstalling Eclipse may help.

JNI Error when starting a Minecraft Server

If you try to start your Minecraft server via the official server.jar (error occurs since version 1.17), you may get this error message:

JNI Error Popup
Java Virtual Machine Launcher: JNI Error Popup

JNI Error in Minecraft TLauncher

This error message can also appear when launching the Minecraft TLauncher.

Java JDK Download Page
Java JDK Download Page
  • Right-click on the downloaded file and click “Extract here”.
  • Copy the unzipped folder to the directory C:\Program Files\Java
  • Launch your Minecraft TLauncher and click on the gear in the bottom right corner
  • Click at “Java path” on “Browse…” and choose C:\Program Files\Java\jdkX\bin\javaw.exe (replace the X by the name of your JDK folder).
  • Save everything – now the game should start again

Java JNI error message still appears?

  • Restart your computer
  • Uninstall old Java versions under Control Panel > Programs > Programs and Features and install the latest Java JRE and Java SDK.

I hope that you were able to fix the JNI error with the help of this post. If this is still not the case, feel free to write me a comment.

Related Posts
Join the Conversation

39 Comments

  1. Bhaskar says:

    I have a shell script where I am calling spark2-submit command to call my jar. It throws an error as per below, but it runs OK if I run the same spark2-submit command manually.Error: A JNI error has occurred, please check your installation and try againException in thread “main” java.lang.NoClassDefFoundError: org/slf4j/Logger at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.privateGetMethodRecursive(Class.java:3048) at java.lang.Class.getMethod0(Class.java:3018) at java.lang.Class.getMethod(Class.java:1784) at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:650) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:632)Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger at java.net.URLClassLoader.findClass(URLClassLoader.java:387) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) … 7 more

  2. 11 says:

    is not working

  3. Riley says:

    I do not see a gear icon in launcher? Where is it so how do I change the Java path?

    1. Lorenz says:

      In the bottom right corner it should be

  4. Simon Gillessen says:

    I am in the same situation as the comment: “Hi, I got as far as the part where you look for the installation path of your JDK, and I didn’t see the entry so I clicked on new but it didn’t do anything. Then I clicked on the link that you put for if you haven’t installed the JDK, but I’m not sure what I’m supposed to download once I get there. Any help would be amazing, I have no clue what I’m doing but this tutorial was very easy to follow up until the point that I got lost so thank you!”I downloaded the software you told the user to download but I don’t know how to use this software?! it’s just a casual win.rar document that does nothing.

    1. Lorenz says:

      You are under Windows? Just download the “x64 Installer”. This is an exe-file that installs the JDK.

      Hope this helps! 🙂

  5. Pingback: My Homepage
  6. Tate Hayman says:

    Thank you so much for the help! It worked perfectly!

  7. Eglantine says:

    Hi, I started to do as you explained but when I select “Path” in the lower window of the environment variables, I can’t press any button : not edit, nor new, nor erase… But the upper window allows me to press those buttons. Could you please help me with this ?Thanks in advance

    1. Lorenz says:

      Are you logged in as administrator? Maybe this is the problem…

      1. Vicky says:

        And what can I do if I can’t access to the administrator account?…

      2. Vicky says:

        And if I can’t access to the administrator account, what can I do?…

        1. Lorenz says:

          I’m not sure. Then you won’t be able to customize them….

          Search in Windows for “Enviroment”, there are also local environment variables, which are only for your account. Maybe you can adjust them and fix the problem.
  8. Majo says:

    Wow! It worked Thanks a lot!

  9. Aiden says:

    I dont understand the last step what do i have to do in command propmt

    1. Lorenz says:

      For example, if your error occurred when running in CMD (e.g. java -jar test.jar), you can try again afterwards. If you had the error somewhere else you don’t need to do that of course.

  10. Breanna says:

    Hi, I got as far as the part where you look for the installation path of your JDK, and I didn’t see the entry so I clicked on new but it didn’t do anything. Then I clicked on the link that you put for if you haven’t installed the JDK, but I’m not sure what I’m supposed to download once I get there. Any help would be amazing, I have no clue what I’m doing but this tutorial was very easy to follow up until the point that I got lost so thank you!

    1. Lorenz says:

      Hi, on this page is a link called “JDK Download” unter de “Oracle JDK” headline. You need to download and install this software. Hope this helps! 🙂

      1. Liam says:

        There is not link called JDK download

          1. Kat says:

            Hello! I’m stuck on this part too. Which download link is the one I need to get for Windows Java 8?

          2. Lorenz says:

            Java 8 is already a bit older. So the JDK Download for this version should be here: http://jdk.java.net/java-se-ri/8-MR3

  11. Thunder_Cube says:

    ERRM Please help it won’t work it keeps saying it what do i do?

  12. defo says:

    thankyou bro, its work 100%

  13. suresh says:

    super…thank a lot bro…..

  14. Omer says:

    It worked, thank you!

  15. Bun says:

    Thank you so much, i’t’s been a headache for weeks, I’ve even reinstall but it didn’t work, until I saw your post, it worked , thank you

    1. Lorenz says:

      You’re welcome

  16. Sohibnut says:

    Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you!

    1. Lorenz says:

      🙂

  17. a says:

    didnt fix it

  18. AN Subramanian says:

    Thank you. It worked and saved my time. Grateful.

    1. Lorenz says:

      No problem. 🙂

    1. Lorenz says:

      Thanks

  19. Abiola says:

    Many thanks!

    1. Lorenz says:

      Gladly! 🙂

  20. Lalitha says:

    Thank you very much. It worked.

    1. Lorenz says:

      I’m glad, thanks for the feedback! 🙂

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

bold italic underline strikeThrough
insertOrderedList insertUnorderedList outdent indent
removeFormat
createLink unlink
code

This can also interest you