Java:util_USBUIRT.dll:找不到依赖库 [英] Java: util_USBUIRT.dll: Can't find dependent libraries

查看:177
本文介绍了Java:util_USBUIRT.dll:找不到依赖库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要使用此JAR文件( http://sourceforge.net/projects/uirt-j / )。在Eclipse中,我使用项目> Java构建路径>添加外部JAR来导入它。我可以看到所有类的JAR文件在Ecplise。这个JAR包含两个dll文件。为了加载dll,我把System32 dir,但是当一个执行我的代码,我得到以下错误:

I want to use this JAR file (http://sourceforge.net/projects/uirt-j/) in my project. In Eclipse I used th option Project > Java Build Path > Add External JARs to import it. I can see all classes of JAR file in Ecplise. This JAR contains two dll files. In order to load dlls, I put into System32 dir, but when a execute my code, a I get the follow error:

Exception in thread "main" java.lang.UnsatisfiedLinkError:
C:\Windows\System32\util_USBUIRT.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at util.USBUIRT.<clinit>(USBUIRT.java:269)
at Uirt.main(Uirt.java:6)

使用Dependence Walker我可以看到所有的DLL都在System32文件夹中。我的代码:

Using Dependence Walker I can see that all DLLs are in System32 folder. My Code:

import util.USBUIRT;
public class Uirt {
public static void main(String[] args) {
    String code = "0000";   
    try {
        USBUIRT.transmitIR(code, 2, 3, 2);
    } catch (Exception e) {
        e.printStackTrace();
    }
  }
}

如果单独执行JAR,工作正常。谢谢。 (Windows 7x64)

If JAR is executed alone, that works fine. Thanks. (Windows 7x64)

推荐答案

提到的jar中的dll是32位。环境是Win7 x64。我假设JVM是32位,否则会有另一个错误,即:无法在AMD 64位平台上加载IA 32位.dll 或类似的。

The dlls in the mentioned jar are 32 bit. The environment is Win7 x64. I assume the JVM is 32 bit otherwise there would be another error, ie: Can't load IA 32-bit .dll on a AMD 64-bit platform or similar.

尝试将dll复制到 C:\Windows \SysWOW64 ,而不是 C :\Windows \System32 。 32位dll应该进入 C:\Windows \SysWOW64 。它为我工作,虽然我有 util.USBUIRT $ NotInitializedException 这可能是指示库正确加载。

Try copying the dlls into C:\Windows\SysWOW64 rather than C:\Windows\System32. 32 bits dlls should go into C:\Windows\SysWOW64. It worked for me, although I got util.USBUIRT$NotInitializedException which is probably the indication the libraries were loaded properly.

文件系统重定向器文章可以阐明 SysWOW64 vs System32

File System Redirector article may shed some light on SysWOW64 vs System32.

编辑:调整java.library.path

tweaking java.library.path

您还可以使用注释中提到的解决方案,例如将dll复制到 C:\tmp 中,并使用参数运行:

You may also go with a solution mentioned in comments, for example, copy dlls into C:\tmp and run with argument:

-Djava.library.path="C:\tmp;${env_var:PATH}"

但是因为两个dll之间有一个依赖关系,所以 C:\tmp code> PATH 。否则仍然有 UnsatisfiedLinkError 。手动加载 uuirtdrv.dll 应该有帮助,例如:

But since there is a dependency between the two dlls, C:\tmp must be on PATH. Otherwise there is still UnsatisfiedLinkError. Manually loading uuirtdrv.dll should help, ie:

import util.USBUIRT;
public class Uirt {
    static {
        System.loadLibrary("uuirtdrv");
    }

public static void main(String[] args) {
    String code = "0000";   
    try {
        USBUIRT.transmitIR(code, 2, 3, 2);
    } catch (Exception e) {
        e.printStackTrace();
    }
  }
}

这篇关于Java:util_USBUIRT.dll:找不到依赖库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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