packet capturing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • visal
    New Member
    • Jan 2007
    • 1

    packet capturing

    hi
    Please help me.i am developing a java pgm to capture network packets using jpcap.i downloded jpcap and wpcap dll files.
    My pgm is:

    Code:
    import jpcap.JpcapHandler;
    import jpcap.Jpcap;
    import jpcap.Packet;
    public class sample implements JpcapHandler {
    public void handlePacket(Packet packet){
    System.out.println(packet);
    }
    public static void main(String[] args) throws java.io.IOException{
    String[] devices = Jpcap.getDeviceList();
    for (int i = 0; i < devices.length; i++) {
    System.out.println(devices);
    }
    String deviceName = devices[0];
    Jpcap jpcap = Jpcap.openDevice(deviceName, 1028, false, 1);
    jpcap.loopPacket(-1, new sample());
    }
    }
    when i run this pgm i got the following errors.
    
    C:\Program Files\Java\jre1.5.0\bin>javac sample.java
    sample.java:1: cannot find symbol
    symbol : class JpcapHandler
    location: package jpcap
    import jpcap.JpcapHandler;
    ^
    sample.java:2: cannot find symbol
    symbol : class Jpcap
    location: package jpcap
    import jpcap.Jpcap;
    ^
    sample.java:3: cannot find symbol
    symbol : class Packet
    location: package jpcap
    import jpcap.Packet;
    ^
    sample.java:5: cannot find symbol
    symbol: class JpcapHandler
    public class sample implements JpcapHandler {
    ^
    sample.java:6: cannot find symbol
    symbol : class Packet
    location: class sample
    public void handlePacket(Packet packet){
    ^
    sample.java:11: cannot find symbol
    symbol : variable Jpcap
    location: class sample
    String[] devices = Jpcap.getDeviceList();
    ^
    sample.java:19: cannot find symbol
    symbol : class Jpcap
    location: class sample
    Jpcap jpcap = Jpcap.openDevice(deviceName, 1028, false, 1);
    ^
    sample.java:19: cannot find symbol
    symbol : variable Jpcap
    location: class sample
    Jpcap jpcap = Jpcap.openDevice(deviceName, 1028, false, 1);
    ^
    Help me please. Whats the problem in this code and tell me how to set classpath.
    Last edited by Markus; Sep 24 '10, 10:02 AM. Reason: Added [code] tags
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by visal
    hi
    Please help me.i am developing a java pgm to capture network packets using jpcap.i downloded jpcap and wpcap dll files.
    My pgm is:

    import jpcap.JpcapHand ler;
    import jpcap.Jpcap;
    import jpcap.Packet;
    public class sample implements JpcapHandler {
    public void handlePacket(Pa cket packet){
    System.out.prin tln(packet);
    }
    public static void main(String[] args) throws java.io.IOExcep tion{
    String[] devices = Jpcap.getDevice List();
    for (int i = 0; i < devices.length; i++) {
    System.out.prin tln(devices);
    }
    String deviceName = devices[0];
    Jpcap jpcap = Jpcap.openDevic e(deviceName, 1028, false, 1);
    jpcap.loopPacke t(-1, new sample());
    }
    }
    when i run this pgm i got the following errors.

    C:\Program Files\Java\jre1 .5.0\bin>javac sample.java
    sample.java:1: cannot find symbol
    symbol : class JpcapHandler
    location: package jpcap
    import jpcap.JpcapHand ler;
    ^
    sample.java:2: cannot find symbol
    symbol : class Jpcap
    location: package jpcap
    import jpcap.Jpcap;
    ^
    sample.java:3: cannot find symbol
    symbol : class Packet
    location: package jpcap
    import jpcap.Packet;
    ^
    sample.java:5: cannot find symbol
    symbol: class JpcapHandler
    public class sample implements JpcapHandler {
    ^
    sample.java:6: cannot find symbol
    symbol : class Packet
    location: class sample
    public void handlePacket(Pa cket packet){
    ^
    sample.java:11: cannot find symbol
    symbol : variable Jpcap
    location: class sample
    String[] devices = Jpcap.getDevice List();
    ^
    sample.java:19: cannot find symbol
    symbol : class Jpcap
    location: class sample
    Jpcap jpcap = Jpcap.openDevic e(deviceName, 1028, false, 1);
    ^
    sample.java:19: cannot find symbol
    symbol : variable Jpcap
    location: class sample
    Jpcap jpcap = Jpcap.openDevic e(deviceName, 1028, false, 1);
    ^

    Help me please. Whats the problem in this code and tell me how to set classpath.
    Have a look at

    Comment

    Working...