/**
* This example is similar to the classic libpcap example shown in nearly every
* tutorial on libpcap. The main difference is that a file is opened instead of
* a live network interface. Using a packet handler it goes into a loop to read
* a few packets, say 10. Prints some simple info about the packets, and then
* closes the pcap handle and exits.
*
* Here is the output generated by this example :
*
* Opening file for reading: tests/test-l2tp.pcap
* Received at Tue Jan 27 16:17:17 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:17 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:18 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:18 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:19 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:19 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:20 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:20 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:21 EST 2004 caplen=114 len=114 jNetPcap rocks!
* Received at Tue Jan 27 16:17:21 EST 2004 caplen=114 len=114 jNetPcap rocks!
*
* @author Mark Bednarczyk
* @author Sly Technologies, Inc.
*/
public class offlinecapture {
/**
* Main startup method
*
* @param args
* ignored
*/
public static void main(String[] args) {
/***************************************************************************
* First we setup error buffer and name for our file
**************************************************************************/
final StringBuilder errbuf = new StringBuilder(); // For any error msgs
final String file = "root/new11.pcap";
System.out.printf("Opening file for reading: %s%n", file);
/***************************************************************************
* Second we open up the selected file using openOffline call
**************************************************************************/
Pcap pcap = Pcap.openOffline(file, errbuf);
if (pcap == null) {
System.err.printf("Error while opening device for capture: "
+ errbuf.toString());
return;
}
le problème quand j'éxecute ce code , on m'affiche cete erreur:
run:
Opening file for reading: root/new11.pcap
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jnetpcap in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1860)
at java.lang.Runtime.loadLibrary0(Runtime.java:845)
at java.lang.System.loadLibrary(System.java:1084)
at org.jnetpcap.Pcap.<clinit>(Unknown Source)
at javaapplication14.offlinecapture.main(offlinecapture.java:63)
Java Result: 1
j'aii ajouté le jnetpcap.jar à mon projet mais j'arrive pas à l'éxecuter.
j'ai pas compris pourquoi.