style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-7505528228218001"
data-ad-slot="1225241371">

Running Jnetcap By Using Eclipse IDE

1 reply [Last post]
Ajit samant
Offline
Joined: 05/03/2012

I want to run This coding

import java.nio.ByteBuffer;

import org.jnetpcap.Pcap;
import org.jnetpcap.PcapDLT;
import org.jnetpcap.PcapPktHdr;

public class Live {

public static void main(String arg[])
{

try
{
System.out.println("ajitttt");

System.out.println(System.getProperty("java.library.path"));

StringBuilder errbuf = new StringBuilder();
String file = "messenger.pcap";
System.out.println("ajitttt2");
PcapPktHdr hdr = new PcapPktHdr(); // Capture header, filled in at capture
System.out.println("ajitttt3");
Pcap pcap = Pcap.openOffline(file, errbuf);
if (pcap == null ) {
System.out.println("ajitttt4");
return; }
ByteBuffer buffer = pcap.next(hdr);
if (buffer == null) { return; }

int dlt = pcap.datalink(); // First header type.
pcap.close(); // We're done capturing, only needed 1 packet

if (dlt == PcapDLT.CONST_EN10MB) {
int protocol = buffer.getShort(12); // Get a 16-bit short, at 12th byte in

// convert from signed short, to unsigned short and store in an integer
protocol = (protocol < Innocent?protocol + Short.MAX_VALUE * 2 : protocol;

//
System.out.printf("The value of Ethernet.protocol field is=0x%X\n", protocol);
}

}catch(Exception e){}

}
}

I get this Error..

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.jnetpcap.PcapPktHdr.initIDs()V
at org.jnetpcap.PcapPktHdr.initIDs(Native Method)
at org.jnetpcap.PcapPktHdr.(Unknown Source)
at Live.main(Live.java:26)
ajitttt
C:\lib\jnetpcap-1.3.0
ajitttt2

I use Eclipse IDE.
Use Jar file jnetpcap.jar,
jnetStream3.0a1.jar
i also use jnetpcap.dll
& it is already in my path.

plz help me anyone..

Ajit samant
Offline
Joined: 05/03/2012
Running successful

now this code running successfully...
just add one 2 line..

String file = "E://test//shadowchode.pcap";//provide the path name of .pcap file

System.load("C:\\lib\\jnetpcap-1.3.0\\jnetpcap.dll");//prove the path name of .dll file

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.