1 Reply Latest reply on Mar 19, 2013 9:11 PM by EJP

    Error in Jpcap

      I want to capture netwotk packet for that i have this code

      import java.net.InetAddress;
      import jpcap.net.*;
      import jpcap.*;
      import jpcap.net.EthernetPacket;
      import jpcap.net.IPPacket;
      import jpcap.net.TCPPacket;
      import java.util.Scanner;

      class Capture
      public static void main(String[] args) throws java.io.IOException{
      //Get the Device information - Start

      //Obtain the list of network interfaces
      NetworkInterface[] devices = JpcapCaptor.getDeviceList();

      //for each network interface
      for (int i = 0; i < devices.length; i++) {
      //print out its name and description
      System.out.println(i+": "+devices.name + "(" + devices[i].description+")");

      //print out its datalink name and description
      System.out.println(" datalink: "+devices[i].datalink_name + "(" + devices[i].datalink_description+")");

      //print out its MAC address
      System.out.print(" MAC address:");
      for (byte b : devices[i].mac_address)
      System.out.print(Integer.toHexString(b&0xff) + ":");

      //print out its IP address, subnet mask and broadcast address
      for (NetworkInterfaceAddress a : devices[i].addresses)
      System.out.println(" address:"+a.address + " " + a.subnet + " "+ a.broadcast);
      //Get the Device information - End

      //Capture the packets

      System.out.println("\n \n ");
      System.out.println("Please Enter the Device Name to Capture the Packet");
      Scanner in = new Scanner(System.in);
      int a = in.nextInt();
      if(a <= devices.length)
      int index=a; // set index of the interface that you want to open.

      //Open an interface with openDevice(NetworkInterface intrface, int snaplen, boolean promics, int to_ms)
      JpcapCaptor captor=JpcapCaptor.openDevice(devices[index], 65535, false, 20);
      for(int i=0;i<50;i++){
      //capture a single packet and print it out
      JpcapWriter writer=JpcapWriter.openDumpFile(captor,"s.txt");


      System.out.println("Please Enter the correct value");

      but when i compile this code i get a error saying
      Capture.java:4: error: cannot access EthernetPacket
      import jpcap.net.EthernetPacket;
      bad class file: .\jpcap\net\EthernetPacket.class
      class file contains wrong class: net.sourceforge.jpcap.net.EthernetPacket
      Please remove or make sure it appears in the correct subdirectory of the classpath.