FoxXH0und
FoxXH0und

Reputation: 29

Java network sniffer error issue

I am trying to write a packet sniffer in Java using an old tutorial I found online but having trouble debugging. I am getting an error stating my class pktSniffer is not inheriting an abstract method.

import jpcap.*;
import jpcap.packet.Packet;
import jpcap.PacketReceiver;

public class pktSniffer implements PacketReceiver {

public void handlePacket(Packet packet){

        System.out.println(packet);
}

public static void main(String[] args) throws java.io.IOException{

    NetworkInterface[] lists=jpcap.JpcapCaptor.getDeviceList();

    System.out.println("\n\t\t***Network Sniffer***\n");

    System.out.println("Found the following devices : ");

    for(NetworkInterface s: lists)
    {
        System.out.println("Name: " + s.name +" Description: " + s.description);
    }

    JpcapCaptor jpcap=JpcapCaptor.openDevice(JpcapCaptor.getDeviceList()[1],1000,false,20);
    jpcap.loopPacket(-1,new pktSniffer());

    }
}

Upvotes: 1

Views: 646

Answers (1)

Bert F
Bert F

Reputation: 87503

not inheriting an abstract method

Are you sure that the error wasn't that you are not implementing an abstact method?

According to:

and

your method should be called receivePacket instead of handlePacket

Upvotes: 2

Related Questions