Search code examples
javaeclipsecompiler-errorsjava-8java-native-interface

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


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


Solution

  • 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.