Java问题“UnsatisfiedLinkError” [英] Java Problem "UnsatisfiedLinkError"

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

问题描述

我创建了一个简单的java程序,它将字节发送到并行端口,该端口使用.dll和另外两个类(pPort.java和ioPort.java)来完成它,它完全正常。

I made a simple java program that sends bytes to the parallel port, which uses a .dll along with two other classes (pPort.java and ioPort.java) to accomplish it, and it works perfectly fine.

但是,我开始在NetBeans IDE上创建另一个具有类似功能的程序。它编译得很完美,但是当我运行它时,我得到:

However, I started making another program on NetBeans IDE which has a similar function. It compiles perfectly, but when I run it I get:

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: parallelporttimer.ioPort.Out32(SS)V

根据我的理解,它没有调用.dll文件我放在System32上。但我不明白为什么,因为其他程序,基本相同,但没有任何IDE手动制作,运行正常。我是否必须在NetBeans中指定一些内容才能使用此功能?任何有关这方面的帮助将不胜感激。

From what I understand, it's failing to call the .dll file I put on System32. But I don't understand why, since the other program, which is basically the same but made manually without any IDE, runs fine. Do I have to specify something in NetBeans for this to work? Any help with this would be greatly appreciated.

推荐答案

UnsatisfiedLinkError 消息通常表示库路径已设置,但不包括您尝试加载的库。在Windows平台上,您应该使用

An UnsatisfiedLinkError message typically indicates that the library path is set but does not include the library that you are trying to load. On Windows platforms, you should extend the PATH using

PATH = %PATH%;C:\path_to_dll_file 

在UNIX平台上,您应该使用

On UNIX platforms, you should extend the library path using

setenv LD_LIBRARY_PATH mylibrarypath 

但是,据我所知(我不在Windows下), System32 位于 PATH 所以我怀疑NetBeans通过设置自己的PATH来覆盖它。

However, as far as I can remember (I'm not under Windows), System32 is in the PATH so I suspect NetBeans to overwrite it by settings its own PATH.

要在NetBeans上解决此问题,您可能需要检查 http://wiki.netbeans.org/DevFaqNativeLibraries ,在此消息;)

To solve this on NetBeans, you might want to check http://wiki.netbeans.org/DevFaqNativeLibraries which is mentioned in this message from Wade Chandler, a NetBeans Dream Team Member ;-)

PS:你也可以使用 java.library.path 系统属性但要记住这个系统em属性仅用于解析您在代码中加载的直接本机库。其他依赖库的加载留给第一个库。您加载的JNI库将依赖于操作系统相关的方式来解析其引用(这适用于常见问题的解决方案,因此我仍然不是100%确信它是一个很好的解决方案)。

PS: You can also use the java.library.path system property but keep in mind that this system property only works to resolve the immediate native library that you are loading in your code. Loading of other dependent libraries is left to the first library. The JNI library that you load will rely on the OS dependent way to resolve its references (this applies to the solution of the FAQ too IMO so I'm still not 100% convinced its a good solution).

这篇关于Java问题“UnsatisfiedLinkError”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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