"A JNI Error has occurred" for one instance of the program, not for another

72,774

Solution 1

Eclipse presents different ways to export JAR for a project. To have the native library (or libraries) available when running the exported JAR, choose "package required libraries in generated JAR" option.

Solution 2

JNI means Java Native Interface, meaning the application is trying to load a native library. Those native libraries are NOT part of a compiled jar file. Try to find out what native library is needed for your application, and wheter it is installed on one but not the other machine. Also check your run configuration. Using JNI you need to set the -Djava.libary.path=<...> parameter to point to your native libraries.

Share:
72,774
Robin Kramer-ten Have
Author by

Robin Kramer-ten Have

Graduated from the University of Groningen, master Human-Machine Communication, with the specialization of Cognitive Engineering. I am interested in the interaction between human, task, tool and organization in the hope of improving system performance, efficiency and safety. Currently, I am working as a safety consultant at Royal Netherlands Aerospace Center (Royal NLR). Here, I focus on safety management (policies, risk assessments, safety assurance and promotion) and safety culture (just culture, reporting culture) within the aviation industry. My main interest lie in cognitive psychology and organisational psychology, but always with a quantitative touch. Therefore, I've learned to analyse data using Matlab, Python, VBA and R, and I've learned a bit of programming in C and Java. In the future, I would love to see how machine learning techniques can tackle human factors and organisational issues in the field of aviation.

Updated on July 05, 2022

Comments

  • Robin Kramer-ten Have
    Robin Kramer-ten Have almost 2 years

    I made a large program in Eclipse Java Mars on one computer which worked fine. I exported the program as a runable Jar-file and running it gave no problem whatsoever. Even when I exported the entire project to another computer, the program still works.

    The issue came forth on the other computer when I made minor changes to the project. These changes were only content based changes and should make no difference on the functionality of the program. Running the program from eclipse appears to have no problems. However, when I want to run the newly created Jar-file I get the following error:

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

    followed by a frame saying:

    A Java Exception has occurred. 
    

    So my question is:

    How is it possible that a different instances of the same program cannot run via a Jar-file, while the older instance can?

    I used the same JDK version (1.8.0_73) on both computers, and installed them in pretty much the same way: I first installed Java together with NetBeans via a combined release. Following, I installed Eclipse. The only difference is that on the new computer I installed eclipse offline, i.e. without the Eclipse installer