quot;A JNI Error has occurredquot; for one instance of the program, not for another(“发生了 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 错误"对于程序的一个实例,而不是另一个
基础教程推荐
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01