在Eclipse / PyDev Jython项目中将.dll添加到java.library.path [英] Add .dll to java.library.path in Eclipse/PyDev Jython project
问题描述
我成功地将.jar添加到PYTHONPATH,并且能够开始编码与自动完成工作。
库需要.dll扩展名, javaHeclib.dll
,所以我将其添加到我的项目的外部Libs部分。
我可以导入库,但是当我尝试访问其任何功能时,我收到错误: p>
java.lang.UnsatisfiedLinkError:java.lang.UnsatisfiedLinkError:java.library.path中没有javaHeclib
我在运行配置中添加了一个VM参数,没有运气:
-Djava.library.path =Y:/path/to/javaHeclib.dll; $ {env_var:PATH}
我可以使用上面的 java.library.path
从命令行运行库。
在PyDev控制台中进行实验,我注意到我可以加载.dll扩展名为绝对路径,但不是相对路径:
>>> import java.lang
>>> java.lang.System.load('Y:/path/to/javaHeclib.dll')
>>> java.lang.System.loadLibrary('javaHeclib')
Traceback(最近的最后一次调用):
文件< console>,第1行,in?
java.lang.UnsatisfiedLinkError:java.lang.UnsatisfiedLinkError:java.library.path中的javaHeclib
不幸的是,图书馆正在使用上面的 System.loadLibrary
调用,我没有访问它的来源。
为什么 javaHeclib.dll
不在我的 java.library.path
?
编辑
设置 java.library.path
到包含dll的目录不允许我使用 System.loadLibrary
加载它。
-Djava.library.path =Y:/ path / to / dll /; $ {env_var:PATH}
(使用正斜杠没有任何区别。)我还尝试更改 eclipse.ini
,没有运气:
-vmargs
-Dosgi.requiredJavaVersion = 1.5
-Xms40m
-Xmx384m
-Djava.library.path =Y:\path\to\dll\; $ {env_var:PATH}
我得到了这个工作。
为了将来参考:
说你需要的dll是在 Y:\path\to\dlls\ lib\
。然后将运行配置的工作目录设置为 Y:\path\to\dlls\
,并将您的VM参数设置为包含 -Djava。 library.path = lib
。
就是这样,它现在应该可以工作了。我不知道为什么在 java.library.path
中指定绝对路径以前没有工作,但设置工作目录似乎已经完成了。
也许这是我正在使用的特定库(或者Eclipse是从不同的驱动器运行在库中)特有的东西...
I'm trying to use a compiled .jar Java library in my PyDev Jython project.
I successfully added the .jar to the PYTHONPATH and was able to begin coding with auto complete working.
The library requires a .dll extension as well, javaHeclib.dll
, so I added that to the External Libs section of my project.
I can import the library fine, but I get an error when I try to access any of its functions:
java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: no javaHeclib in java.library.path
I added a VM argument to my Run Configuration, with no luck:
-Djava.library.path="Y:/path/to/javaHeclib.dll;${env_var:PATH}"
I can run the library from the command line just fine using the java.library.path
above.
Experimenting in the PyDev Console, I noticed I can load the .dll extension with an absolute path, but not a relative one:
>>> import java.lang
>>> java.lang.System.load('Y:/path/to/javaHeclib.dll')
>>> java.lang.System.loadLibrary('javaHeclib')
Traceback (most recent call last):
File "<console>", line 1, in ?
java.lang.UnsatisfiedLinkError: java.lang.UnsatisfiedLinkError: no javaHeclib in java.library.path
Unfortunately, the library is using the the System.loadLibrary
call above, and I don't have access to its source.
Why is javaHeclib.dll
not in my java.library.path
?
EDIT
Setting the java.library.path
to the directory containing the dll didn't allow me to load it using System.loadLibrary
.
-Djava.library.path="Y:/path/to/dll/;${env_var:PATH}"
(Using forward slashes didn't make a difference.) I also tried changing the default VM args in eclipse.ini
, with no luck:
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx384m
-Djava.library.path="Y:\path\to\dll\;${env_var:PATH}"
I got this working.
For future reference:
Say the dll you need is in Y:\path\to\dlls\lib\
. Then set your Run Configuration's working directory to Y:\path\to\dlls\
and set your VM arguments to include -Djava.library.path=lib
.
That's it, it should now work. I don't know why specifying an absolute path in java.library.path
didn't work previously, but setting a working directory seems to have done it.
Perhaps it's something peculiar to the specific library I'm using (or that Eclipse is running from a different drive than the library is on)...
这篇关于在Eclipse / PyDev Jython项目中将.dll添加到java.library.path的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!