“发生了 JNI 错误"对于程序的一个实例,而不是另一个

quot;A JNI Error has occurredquot; for one instance of the program, not for another(“发生了 JNI 错误对于程序的一个实例,而不是另一个)

本文介绍了“发生了 JNI 错误"对于程序的一个实例,而不是另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一台运行良好的计算机上用 Eclipse Java Mars 编写了一个大型程序.我将该程序导出为一个可运行的 Jar 文件并运行它没有任何问题.即使我将整个项目导出到另一台计算机,该程序仍然有效.

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.

当我对项目进行细微更改时,问题出现在另一台计算机上.这些更改只是基于内容的更改,不应影响程序的功能.从 Eclipse 运行程序似乎没有问题. 但是,当我想运行新创建的 Jar 文件时,出现以下错误:

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. 

后跟一个框架说:

A Java Exception has occurred. 

所以我的问题是:

为什么同一程序的不同实例不能通过 Jar 文件运行,而旧实例可以?

我在两台计算机上使用相同的 JDK 版本 (1.8.0_73),并以几乎相同的方式安装它们:我首先通过组合版本将 Java 与 NetBeans 一起安装.接下来,我安装了 Eclipse.唯一的区别是我在新电脑上离线安装了eclipse,即没有安装Eclipse

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

推荐答案

Eclipse 提供了为项目导出 JAR 的不同方法.要在运行导出的 JAR 时使用本机库(或多个库),请选择在生成的 JAR 中打包所需的库"选项.

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.

这篇关于“发生了 JNI 错误"对于程序的一个实例,而不是另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:“发生了 JNI 错误"对于程序的一个实例,而不是另一个

基础教程推荐