pingpengmang3019
ee2333
2017-11-29 09:32

jpcap运行在eclipse报错 ,求大神

  • eclipse

Exception in thread "main" java.lang.NoClassDefFoundError: jpcap/JpcapCaptor
at jptext.jptext.main(jptext.java:13)
Caused by: java.lang.ClassNotFoundException: jpcap.JpcapCaptor
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more

package jptext;

import jpcap.JpcapCaptor;
import jpcap.NetworkInterface;
import jpcap.PacketReceiver;
import jpcap.packet.Packet;

public class jptext {
public static void main(String args[]){
try{
//获取本机上的网络接口对象数组
final NetworkInterface[] devices = JpcapCaptor.getDeviceList();
for(int i=0;i<devices.length;i++){
NetworkInterface nc=devices[i];
//一块卡上可能有多个地址:
String address="";
for(int t=0;t<nc.addresses.length;t++){
address+="|addresses["+t+"]: "+nc.addresses[t].address.toString();
}
//打印说明:
System.out.println("第"+i+"个接口:"+"|name: "+nc.name
+"|loopback: "+nc.loopback+"\r\naddress: "+address);
}

    }catch(Exception ef){
        ef.printStackTrace();
 System.out.println("显示网络接口数据失败:  "+ef);
}

}
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐