Jar 和 java.library.path
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20056934/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jar and java.library.path
提问by skiwi
I am trying to use DLL's from a specific place from the disk (because I am using JNotify library).
我正在尝试从磁盘的特定位置使用 DLL(因为我使用的是 JNotify 库)。
Using Netbeans 7.4, the following happened:
使用 Netbeans 7.4,发生了以下情况:
My temporary program only does:
我的临时程序只做:
System.out.println(System.getProperty("java.library.path"));
System.out.println(System.getProperty("java.library.path"));
As VM options in Netbeans I have set: -Djava.library.path=D:/JNotify-dll/
. Program outputs: D:/Jnotify-dll/
.
作为 Netbeans 中的 VM 选项,我设置了:-Djava.library.path=D:/JNotify-dll/
. 程序输出:D:/Jnotify-dll/
.
When I run it as normal java <jarfile>
: It gives main class not set, while I did set it in Netbeans options.
当我正常运行它时java <jarfile>
:它没有设置主类,而我确实在 Netbeans 选项中设置了它。
When I run it as java -jar <jarfile>
: It gives me my %PATH%
variable.
当我运行它时java -jar <jarfile>
:它给了我我的%PATH%
变量。
When I run it as java -jar <jarfile> -Djava.library.path=D:/JNotify-dll/
it stillgives me my %PATH%
variable.
当我运行它时,java -jar <jarfile> -Djava.library.path=D:/JNotify-dll/
它仍然给我我的%PATH%
变量。
Does anyone have any clue what is going on? I am getting real tired of it.
有谁知道发生了什么?我真的厌倦了。
The MANIFEST.MF
generated by Netbeans:
在MANIFEST.MF
通过Netbeans的生成:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.1
Created-By: 1.7.0_25-b17 (Oracle Corporation)
Class-Path: lib/ORM.jar lib/mysql-connector-java-5.1.23-bin.jar lib/co
mmons-dbcp-1.4-javadoc.jar lib/commons-dbcp-1.4.jar lib/commons-pool-
1.6-javadoc.jar lib/commons-pool-1.6.jar lib/jnotify-0.94.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: bf4.bf4logreader.BF4LogReader
EDIT:java -jar -Djava.library.path=D:/JNotify-dll/ <jarfile>
, but I'd still appreciate an answer.
编辑:java -jar -Djava.library.path=D:/JNotify-dll/ <jarfile>
,但我仍然很感激答案。
采纳答案by kaliatech
You need to change the order of your command line arguments:
您需要更改命令行参数的顺序:
java -Djava.library.path=D:/JNotify-dll/ -jar <jarfile>
See also:
也可以看看: