为什么会出现java.lang.UnsatisfiedLinkError:无法加载库? [英] Why do I get java.lang.UnsatisfiedLinkError: Unable to load library?

查看:98
本文介绍了为什么会出现java.lang.UnsatisfiedLinkError:无法加载库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JNA从Java应用程序调用.dll文件.我收到以下异常:

I am trying to call a .dll file from my Java app using JNA. I am getting the following exception:

线程主"中的异常java.lang.UnsatisfiedLinkError:无法加载库'C:\ Windows \ System32 \ foo.dll':找不到指定的模块.

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'C:\Windows\System32\foo.dll': The specified module could not be found.

.dll和我的jdk均为32位(OS_ARCH ="i586"),尽管我在64位Windows 7 PC上运行它.
.dll在System32文件夹中.

Both the .dll and my jdk are 32 bit (OS_ARCH="i586") although I am running it on a 64 bit Windows 7 PC.
The .dll is in the System32 folder.

我正在使用Eclipse,并且已将System32文件夹添加到Java Build Path Properties中库"选项卡下"JRE系统"库中的本机库位置(尽管我认为这不是必需的).

I am using Eclipse and have added the System32 folder to the Native library location in the JRE System library under the Libraries tab in the Java Build Path Properties (although I don't think this should be necessary).

如果有任何帮助或建议,我将不胜感激.
谢谢,
-蒙克.

I would be grateful for any help or suggestions.
Thanks,
-Munk.

推荐答案

这是下降到文件系统重定向器.您正在WOW64仿真器下执行,该仿真器在64位系统上模拟32位Windows.在WOW64下,将 system32 重定向到 SysWOW64 .您需要将DLL放在那里.

This is down to the file system redirector. You are executing under the WOW64 emulator that emulates 32 bit Windows on a 64 bit system. Under WOW64, the system32 is redirected to SysWOW64. You'll need to put your DLL there.

话虽如此,系统目录由系统拥有并为系统专有.您应该不要将DLL放入系统目录中.您应该找到一种将DLL放置在其他位置的方法.

With that said, the system directory is owned by, and private to, the system. You are expected not to put DLLs into the system directory. You should find a way to put your DLL in some other location.

这篇关于为什么会出现java.lang.UnsatisfiedLinkError:无法加载库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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