简体   繁体   English

不满意的链接错误帮助Java JNI Eclipse

[英]Unsatisfied Link Error Help Java JNI Eclipse

Hi I am trying to run a project in eclipse and am getting the runtime error: 嗨,我想在eclipse中运行一个项目,并得到运行时错误:

Exception in thread "main" java.lang.UnsatisfiedLinkError: mywrapperclass.nativemethod()V 线程“main”中的异常java.lang.UnsatisfiedLinkError:mywrapperclass.nativemethod()V

I only get the error code when I call a native method in the wrapper class from my main. 当我从main中调用包装类中的本机方法时,我只得到错误代码。 I have looked around on many forums and blogs/websites and haven't been able to fix this. 我浏览了许多论坛和博客/网站,但未能解决这个问题。 Debug and my browsing have me led me to thinking that the problem lies in the project not being able to find the native methods within the dll. 调试和我的浏览让我认为问题在于项目无法在dll中找到本机方法。

I had a lot of trouble getting eclipse to find the .dll and eventually solved this by placing the dll in the system32 folder. 我在使用eclipse找到.dll时遇到了很多麻烦,并最终通过将dll放在system32文件夹中解决了这个问题。

Thanks in advance 提前致谢

Project > Properties > Java Build Path 项目>属性> Java构建路径

Click on the arrow of the JAR that needs the DLL library. 单击需要DLL库的JAR箭头。

Native library location 本机库位置

You have to specify the location of the DLL library. 您必须指定DLL库的位置。

  1. open .classpath in the project location 在项目位置打开.classpath
  2. Set the dll path as "value" for "CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" attribute 将dll路径设置为“CLASSPATH_ATTR_LIBRARY_PATH_ENTRY”属性的“值”

Easiest way to bundle the dlls with eclipse plugin is 用eclipse插件捆绑dll的最简单方法是

create a folder structure under the plugin like this "os/win32/x86" for x86 architecture and place your dlls there. 在插件下创建一个文件夹结构,如x86架构的“os / win32 / x86”,并将你的dll放在那里。

and load the libraries like this in your plugin code System.loadLibrary("Dll name"); 并在您的插件代码System.loadLibrary(“Dll name”)中加载这样的库;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM