java loadlibrary,从64位jdk切换到32位后,Java loadLibrary()无法找到库

I am attempting to load a native library which accordingly loads an original dll. However on another computer running XP 32bit, it works fine. When executed on a win7 64 bit system it would fail to load. On the xp machine, the dll files could be in same directory as class files, however in order to not get a unsatisfied link error, i had to copy the files into the system32 folder. Then it gave an error stating that a 32bit dll cannot be loaded on a 64 bit process. I downloaded the 32 bit jdk and set the jdk in the project to load the 32 bit jdk. When that was complete i again got an Unsatisfied link error, and the files are still in system32 as well as next to the class files. I am confused as to why it would find the library when using 64 bit jdk and will not in 32 bit jdk.

...

static {

System.loadLibrary("K8055jni");

}

Exception in thread "main" java.lang.UnsatisfiedLinkError: no K8055jni in java.library.path

at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)

at java.lang.Runtime.loadLibrary0(Runtime.java:845)

at java.lang.System.loadLibrary(System.java:1084)

at K8055jni.(K8055jni.java:50)

at Test.main(Test.java:4)

How do i get the 32 bit jdk to locate the same files?

解决方案

IF I understand your question and problem correctly, then you might try either of:

Windows 7 place your 32-bit DLLs into \Windows\SysWOW64 instead of \Windows\System32. Oddly enough, under Win 7, System32 is for 64-bit binaries only. See this and this for details.

Better still, place your binary files in an application folder, and specify on the java command line:

-Djava.library.path=

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值