Loading DLL in Java - Eclipse - JNI(在 Java 中加载 DLL - Eclipse - JNI)
问题描述
我正在尝试使用以下代码在 java 中加载 dllSystem.loadLibrary("mydll");
I am trying to load a dll in java using the following code System.loadLibrary("mydll");
项目位于 D:developmentproject 中,我已将 dll 放在 D: 中.然后我在eclipse配置中给出了以下VM参数-Djava.library.path=D:/
The project is placed in D:developmentproject and i have placed the dll on D:. I then gave following VM argument in eclipse configuration -Djava.library.path=D:/
但是当我运行时,我得到 UnsatisifiedLinkerError.谷歌搜索了一下后,我用System.load("D:mydll.dll");
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?
推荐答案
在库路径中指定 DLL 文件名的地方,省略它.此外,您的 System.loadLibrary 调用应该只是mydll".我可以告诉您(根据经验),如果您将 DLL 放在 Eclipse 中项目的根目录中(即 D:Eclipse WorkspaceProj),它应该工作.任何进一步的链接器错误都可能来自于查找其他 DLL 的依赖性问题.例外是一样的.使用 Dependency Walker (http://www.dependencywalker.com/) 之类的东西来查看您的 DLL 是否依赖不在系统库路径上的任何其他内容.
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 WorkspaceProj), 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.
UnsatisfiedLinkError:如果 Java 虚拟机找不到声明为本地的方法的适当本地语言定义,则抛出 - 似乎您正在使用不存在的 JNI 函数.
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Java 中加载 DLL - Eclipse - JNI
基础教程推荐
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
