运行使用jNetPcap jar的javacode时收到以下错误:
Exception in thread "main" java.lang.UnsatisfiedLinkError: com.slytechs.library.NativeLibrary.dlopen(Ljava/lang/String;)J
at com.slytechs.library.NativeLibrary.dlopen(Native Method)
at com.slytechs.library.NativeLibrary.<init>(Unknown Source)
at com.slytechs.library.JNILibrary.<init>(Unknown Source)
at com.slytechs.library.JNILibrary.loadLibrary(Unknown Source)
at com.slytechs.library.JNILibrary.register(Unknown Source)
at com.slytechs.library.JNILibrary.register(Unknown Source)
at com.slytechs.library.JNILibrary.register(Unknown Source)
at org.jnetpcap.Pcap.<clinit>(Unknown Source)
at PacketExtractor.main(PacketExtractor.java:51)
我试图做的是打开一个.pcap文件,我将读取或提取其中的一些DNS类型A数据包,为此,我准备了eclipse环境并添加了与jNetPcap相关的jar,如本网页中所述:http://researchingtech.wordpress.com/2012/10/21/installing-jnetpcap-on-windowseclipse-users/
然后我添加了这部分代码:
final String FILENAME = "C:\\Users\\Administrator\\Downloads\\dns.cap";
final StringBuilder errbuf = new StringBuilder();
final Pcap pcap = Pcap.openOffline(FILENAME, errbuf);
if (pcap == null) {
System.err.println(errbuf); // Error is stored in errbuf if any
return;
}
然后,当我编译项目时,我收到了上述错误!
有谁知道我在导致错误的步骤中错过了什么?
请指教..
最佳答案
当找不到代码正在寻找的so / dll文件时,会发生此错误。请确保在Windows system32文件夹中保存了jnetpcap的.dll文件。