在eclipse中使用额外的本机代码库导出到Runnable jar [英] Exporting to Runnable jar with extra native code libraries in eclipse
问题描述
我无法将我的java项目从eclipse导出为jar可执行文件。我的java项目使用外部库(称为jri)。我已经导出了jri.jar文件并在eclipse中为其本机库设置了库路径,并且它在eclipse中的开发效果很好。但是,当我将其导出为可执行jar文件时,我收到以下错误:
I am having trouble exporting my java project from eclipse as a jar executable file. My java project uses an external library (its called jri). I have exported the jri.jar file and set the library path for its native library in eclipse, and it works great in development in eclipse. However, when I export it as an executable jar file I get the following error:
Cannot find JRI native library!
Please make sure that the JRI native library is in a directory listed in java.library.path.
我已将一个名为lib的文件夹放在与项目jar相同的目录中;这个lib文件夹包含jri的本机库。 jri的本机库不在一个文件中,而是在一个文件夹中。这与我在eclipse中的设置相同。
I have placed a folder called lib in the same directory as my project's jar; this lib folder contains jri's native library. jri's native library is not in one file but in a folder. This is the same setup I have in eclipse.
我在eclipse中导出项目的方式是
The way I am exporting my project in eclipse is
Export...
Java > Runnable JAR file
Copy required libraries into a sub folder next to the generated Jar
Finish
我的文件夹就像这样组织了
And my folder is organized like this
folder project
project.jar
project_lib
jri.jar
jri native library folder
我项目的MANIFEST.MF。 jar是:
The MANIFEST.MF of my project.jar is:
Manifest-Version: 1.0
Class-Path: . project_lib/jri.jar
Main-Class: index
我想要实现的是给另一个人一个文件夹,包括project.jar和其他所需的东西,这样她/他就可以运行它,而无需安装任何其他东西。
非常感谢
What I want to achieve is to give another person a folder including project.jar and anything else needed so she/he can run it without needing to install anything else. Thanks so much
推荐答案
添加包含类似内容的脚本:
Add a script containing something like that:
#!/bin/bash
java -Djava.library.path=project_lib/native/ -jar project_lib/jri.jar
我以这种方式导出一些java项目。
I export some java projects that way.
这篇关于在eclipse中使用额外的本机代码库导出到Runnable jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!