java.lang.UnsatisfiedLinkError-本机方法问题 [英] java.lang.UnsatisfiedLinkError - Native method issue

查看:477
本文介绍了java.lang.UnsatisfiedLinkError-本机方法问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Java(Eclipse)中遇到有关dll用法的问题。到目前为止,我遇到以下问题:

 代理SomeAgent 
的未捕获异常java.lang.UnsatisfiedLinkError:SomePackage .SomeClass.SomeNativeMethod(II)Z在jade.core.behaviours.Behaviour.actionWrapper(Behaviour.java:344)
[...]
在jade.core.Agent $ ActiveLifeCycle .execute(Agent.java:1532)
在jade.core.Agent.run(Agent.java:1471)
在java.lang.Thread.run(Thread.java:745)

我不知道这是否有助于解决问题,但我也在该项目中使用JADE ...



编辑(28/04/2014):



我尝试使用的dll是一个自定义的dll(由我工作所在公司的前雇员创建)。



关于这个问题的奇怪之处在于,我有2个执行类似任务的Java项目。其中一个项目运行完美,而另一个项目则遇到 UnsatisfiedLinkError



关于路径: ve为工作区文件夹中包含的dll创建了一个特定的文件夹,但不在项目文件夹内(换句话说,是 bin src 围兜设置等)。对于我拥有的两个项目,此文件夹的配置均相同。另外,我已经测试了 System.out.println(System.getProperty( java.library.path)方法,在两种情况下都返回了正确的路径。



编辑(29/04/2014):



只需添加一些其他内容有关错误消息的信息,我开始认为该问题可能与JADE的使用有关...

解决方案

此处



将以下内容添加到您的程序中,以识别两个运行时环境之间的体系结构和加载路径之间的差异。

  System.out.println(System.getProperty( java.library.path)) ; 
System.out.println(System.getProperty( sun.arch.data.model));

您可以使用dumpbin.exe实用程序来识别正在加载的DLL所需的依赖项。存在。
用法示例:

  C:> dumpbin / imports your.dll 

文件转储your.dll
文件类型:DLL
该节包含以下导入:
** KERNEL32.dll **

您可以使用where.exe命令查找依赖项的位置。
用法示例:

  C:>其中KERNEL32.dll 
C:\Windows\ System32\kernel32.dll

如果您看到:

  C:>其中KERNEL32.dll 
信息:找不到给定模式
<的文件/ pre>

调查为什么依赖DLL不在路径上。



您可以使用dumpbin.exe命令检查64位和32位。

示例:

  C:> dumpbin / headers yourd.dll 

文件yourd.dll转储
找到PE签名
文件类型:DLL
文件头值
14C机器(x86)<-32位DLL

C:> dumpbin / headers yourd.dll

转储文件yourd.dll
找到PE签名
文件类型:DLL
文件头值
8664计算机(x64)<-64位DLL

主/从属之间的任何32位与64位不匹配。如果您的JVM是32位的,则需要使用32位的DLL。如果您的JVM是64位的,则需要使用64位的DLL。 (可以在64位操作系统上运行32位JVM,但JNI DLL必须为32位(DLL与JVM匹配,而不与操作系统匹配)。


I am experiencing a problem in Java (Eclipse) regarding the usage of dlls. Until now, I am experiencing the following problem:

Uncaught Exception for agent SomeAgent 
java.lang.UnsatisfiedLinkError: SomePackage.SomeClass.SomeNativeMethod(II)Z
[...]
at jade.core.behaviours.Behaviour.actionWrapper(Behaviour.java:344)
at jade.core.Agent$ActiveLifeCycle.execute(Agent.java:1532)
at jade.core.Agent.run(Agent.java:1471)
at java.lang.Thread.run(Thread.java:745)

I don't know if this will help to figure out the problem, but I am also using JADE in this project...

EDIT (28/04/2014):

The dll which I am trying to use is a custom one (was created by an ex-employee from the company where I work).

The curious thing about this problem is that I have 2 java projects which perform similar tasks. One of this projects runs perfectly, while the other one is experiencing the UnsatisfiedLinkError.

About the paths: I've created a specific folder for the dlls which is contained in the workspace folder, but not inside the project folder (in other words, the same folder where bin, src, bibs, settings, etc. are). This folder's configuration is equal for the both projects I have. Also, I've already tested the System.out.println(System.getProperty("java.library.path") method and the right path is returned on both cases.

EDIT (29/04/2014):

Just added some additional information regarding the error messages. I am starting to think that the problem may be related to the JADE usage...

解决方案

Here is a PD procedure that might help you identify the problem.

Add the following to your program to identify the differences in the arch and load paths between the two runtime environments. Investigate any differences in path/arch.

 System.out.println(System.getProperty("java.library.path"));
 System.out.println(System.getProperty("sun.arch.data.model"));

You can use the dumpbin.exe utility to identify the dependencies needed by the DLL that is being loaded. Make sure the dependencies exist. Example usage:

C:> dumpbin /imports your.dll 

Dump of file your.dll
File Type: DLL
  Section contains the following imports:
    **KERNEL32.dll**

You can use the where.exe command to find the location of the dependencies. Example usage:

C:>where KERNEL32.dll
    C:\Windows\System32\kernel32.dll

If you see:

C:>where KERNEL32.dll
    INFO: Could not find files for the given pattern(s)

Investigate why the dependent DLL is not on the path.

You can use the dumpbin.exe command to check 64bit vs 32bit.
Example:

C:>dumpbin /headers yourd.dll

 Dump of file yourd.dll
 PE signature found
 File Type: DLL
 FILE HEADER VALUES
         14C machine (x86)    <-- 32bit DLL

C:>dumpbin /headers yourd.dll

 Dump of file yourd.dll
 PE signature found
 File Type: DLL
 FILE HEADER VALUES
         8664 machine (x64)    <-- 64bit DLL

Investigate any 32bit vs 64bit mismatches between main/dependent. If your JVM is 32bit, you need to use 32bit DLLs. If your JVM is 64bit, you need to use 64bit DLLs. ( It is okay to run a 32bit JVM on a 64bit OS but the JNI DLLs must be 32bit ( DLLs match the JVM not the OS ).

这篇关于java.lang.UnsatisfiedLinkError-本机方法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆