在Java中加载DLL - Eclipse - JNI [英] Loading DLL in Java - Eclipse - JNI
问题描述
System.loadLibrary(mydll);
该项目放在D :\development\project\我已将dll放在D:上。然后我在eclipse配置中给出了以下VM参数
-Djava.library.path = D:/
但是当我运行我得到 UnsatisifiedLinkerError 。 googling之后,我使用
System.load(D:\mydll.dll);
但再次遇到同样的问题,有人可以可以帮助?
在库路径中指定DLL文件名,请忽略。另外,您的System.loadLibrary调用应该是'mydll'。我可以告诉你(从经验),如果你将DLL放在Eclipse的项目根目录(即D:\Eclipse Workspace\Proj)中,那么它应该工作。任何进一步的链接器错误可能来自于查找其他DLL的依赖性问题。异常是一样的。使用Dependency Walker( http://www.dependencywalker.com/ )来查看您的DLL是否依赖于任何其他不在系统库路径上的东西。
编辑: UnsatisfiedLinkError :如果Java虚拟机找不到适当的本地语言定义一种声明为native的方法,好像您正在使用不存在的JNI函数。
I am trying to load a dll in java using the following code System.loadLibrary("mydll");
The project is placed in D:\development\project\ and i have placed the dll on D:. I then gave following VM argument in eclipse configuration -Djava.library.path=D:/
But when i run i get UnsatisifiedLinkerError. After googling a bit, I used System.load("D:\mydll.dll");
but again getting the same problem, could someone can help?
Where you specify the DLL filename in the library path, omit that. Additionally, your System.loadLibrary call should just be 'mydll'. I can tell you (from experience) that if you put the DLL in the root of your project in Eclipse (i.e., D:\Eclipse Workspace\Proj), it should work. Any further linker errors could be from dependency problems with finding other DLLs. The exception is the same. Use something like Dependency Walker (http://www.dependencywalker.com/) to see if your DLL relies on anything else not on the system library path.
Edit: UnsatisfiedLinkError: Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native -- it seems like you are using a JNI function which does not exist.
这篇关于在Java中加载DLL - Eclipse - JNI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!