[英]I get this "UnsatisfiedLinkError " while trying to use the jpcap Java library
使用:windows 10、VScode,intel cpu。 將 jar 文件導入我的項目並運行 Github 中的示例代碼后出現此錯誤。
import net.sourceforge.jpcap.capture.*;
import net.sourceforge.jpcap.net.*;
/**
* jpcap Tutorial - Example 5
*
* @author Jonas Lehmann and Patrick Charles
* @version $Revision: 1.2 $
* @lastModifiedBy $Author: pcharles $
* @lastModifiedAt $Date: 2001/07/02 16:44:21 $
*
* Run example and then initiate a ping on the network.
* The example will produce output only if ICMP (ping)
* packets are captured.
*/
public class App
{
private static final int INFINITE = -1;
private static final int PACKET_COUNT = INFINITE;
// BPF filter for only capturing ICMP packets
private static final String FILTER = "proto ICMP";
private PacketCapture m_pcap;
private String m_device;
public App() throws Exception {
// Step 1: Instantiate Capturing Engine
m_pcap = new PacketCapture();
// Step 2: Check for devices
m_device = m_pcap.findDevice();
// Step 3: Open Device for Capturing (requires root)
m_pcap.open(m_device, true);
// Step 4: Add a BPF Filter (see tcpdump documentation)
m_pcap.setFilter(FILTER, true);
// Step 5: Register a Listener for jpcap Packets
m_pcap.addPacketListener(new PacketHandler());
// Step 6: Capture Data (max. PACKET_COUNT packets)
m_pcap.capture(PACKET_COUNT);
}
public static void main(String[] args) {
try {
App example = new App();
} catch(Exception e) {
e.printStackTrace();
System.exit(1);
}
}
}
class PacketHandler implements PacketListener
{
private static int m_counter = 0;
private static int m_icmpCounter = 0;
public void packetArrived(Packet packet) {
m_counter++;
if(packet instanceof ICMPPacket)
m_icmpCounter++;
else
System.err.println("Packet slipped thru filter: " +
packet.getClass().getName());
System.out.println("Total Packets: " + m_counter +
" ICMP Packets: " + m_icmpCounter);
}
}
我一直在嘗試使用 C++ 和 java 導入和使用這個庫兩天,歡迎任何幫助
我將 dll 文件從 lib 導入到我的 JDK 目錄,並將 jars 導入到 VScode 中的引用庫中,是的,我的電腦上安裝了 npcap。
jpcap.dll
文件在Java庫路徑上嗎?
將jpcap
路徑添加到系統環境變量中的path中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.