在 Java 中加载 DLL - Eclipse - JNI

Loading DLL in Java - Eclipse - JNI(在 Java 中加载 DLL - 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