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

前端 未结 4 485
慢半拍i
慢半拍i 2021-01-19 05:18

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 w

相关标签:
4条回答
  • 2021-01-19 05:52

    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.

    0 讨论(0)
  • 2021-01-19 06:08
      <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.datacollector.app.DataCollectorServiceRunner</mainClass>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.handlers</resource>
                                </transformer>
                                <transformer
                                    implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.schemas</resource>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
    
    0 讨论(0)
  • 2021-01-19 06:11

    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.

    0 讨论(0)
  • 2021-01-19 06:14

    Please update your JDK to the latest version(JDK 11 or 12), that fix this issue.

    0 讨论(0)
提交回复
热议问题