繁体   English   中英

我在尝试使用 jpcap Java 库时收到此“UnsatisfiedLinkError”

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM