我想捕获数据包但代码会出错

时间:2013-03-03 18:31:20

标签: java ubuntu

当我在ubuntu 2.04上的netbean中运行此代码时,它会给出下面给出的错误

    import java.io.IOException;
    import jpcap.JpcapCaptor;
    import jpcap.NetworkInterface;
    import jpcap.NetworkInterfaceAddress;
    import jpcap.packet.Packet;

      public class JavaApplication1 {
      public static void main(String[] args){
      printNetworkInterfaces();
  captureFromNetworkInterface();
                                       }

  public static void printNetworkInterfaces(){
    System.out.println("Obtain the list of network interfaces");

      NetworkInterface[] devices = JpcapCaptor.getDeviceList();
         for (int i = 0; i < devices.length; i++) {
          System.out.println(i+": "+devices[i].name + "("  
               +devices[i].description+")");
       System.out.println(" datalink: "+devices[i].datalink_name + "(" +     
       devices[i].datalink_description+")");

    System.out.print(" MAC address:");
    for (byte b : devices[i].mac_address)
    System.out.print(Integer.toHexString(b&0xff) + ":");
     System.out.println();
    for (NetworkInterfaceAddress a : devices[i].addresses)
    System.out.println(" address:"+a.address + " " + a.subnet +""+ a.broadcast);
    }
    }

     public static void captureFromNetworkInterface(){
     NetworkInterface[] devices = JpcapCaptor.getDeviceList();
     int index=0;  

//Open an interface with openDevice(NetworkInterface intrface, int snaplen, boolean 

     promics, int to_ms)
    try {
        JpcapCaptor captor=JpcapCaptor.openDevice(devices[index], 65535,  
                    false, 20);
        for(int i=0;i<10;i++){


            //capture a single packet and print it out
            Packet packet = captor.getPacket();
            if(packet!=null)
            {
                System.out.println("Packet " + i + ": ");
                System.out.println("     length - " + packet.len);
                System.out.println("     captured timestamp - " + 
                                    packet.sec);
            }
        }
        captor.close();
    } catch (IOException e) {
    }

           }*/
     }

错误

没有/usr/lib/jvm/java-6-openjdk-i386/jre/lib/netx.jar的文件

没有/usr/lib/jvm/java-6-openjdk-i386/jre/lib/plugin.jar的文件

0 个答案:

没有答案