Hello there, im doing a small program just like a packet sniffer but i have a one problem.Below are the codes which are used to list all the network interfaces and the output will be something like this:

1.Interface Name's: lo / MS TCP Loopback interface


2.Interface Name's: eth0 / Realtek RTL8139 Family PCI Fast Ethernet NIC - Packet Scheduler Miniport

3.Interface Name's: eth1 / Gigabyte WIKG mini PCI WLAN Card - Packet Scheduler Miniport


4.Interface Name's: eth2 / Bluetooth Device (Personal Area Network)

then i created a dialog where a user can select one of the interface to be scan to do a packet analyser, but i don't know how the code will be.

I tried to search around and i came across the jpcap library,. i already tried to use it but it didnt work. i installed the jpcap and even use import jpcap.*; but it still got errors as if it doesnt recognise any syntax such as jpcap.JpcapCaptor or anything related to pcap.

please help me..if there are any alternative to do packet analyzer instead of using jpcap

Thank you

(codes use to list all the network interfaces)

public void actionPerformed(ActionEvent e) {
if (e.getSource() == b1) {
java.net.SocketException se = new java.net.SocketException();
Enumeration enu = NetworkInterface.getNetworkInterfaces();
int i = 1;
while(i < 10 && enu.hasMoreElements()) {
NetworkInterface net = (NetworkInterface)enu.nextElement();
System.out.println(i+"." + "Interface Name's: " + net.getName() + " / " + net.getDisplayName() +"\n");
Enumeration enum2 = net.getInetAddresses();
while (enum2.hasMoreElements()) {
InetAddress address = (InetAddress)enum2.nextElement();
System.out.println("Address: " + address.getHostAddress()+ "\n");
JOptionPane.showInputDialog(null,"Select Interface to be scan", JOptionPane.QUESTION_MESSAGE);
// if(i == 1)///if a user select one of the interface, it will do packet analyzer
catch(java.net.SocketException se){

8 Years
Discussion Span
Last Post by masijade

Define "didn't work".

Judging from the rest of your post though, I think I can safely assume that you didn't add it to your classpath properly.

And, AFAIK, jpcap is the only library for this sort of thing (as Java is not really meant for this time of low-level system interface, anyway).


well it got me errors when i compiled it:

java.lang.NoClassDefFoundError: JpcapTip
Caused by: java.lang.ClassNotFoundException: JpcapTip
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Exception in thread "main"
----jGRASP wedge2: exit code for process is 1.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.