org.jgroups.util.GetNetworkInterfaces Maven / Gradle / Ivy
Go to download
This artifact provides a single jar that contains all classes required to use remote EJB and JMS, including
all dependencies. It is intended for use by those not using maven, maven users should just import the EJB and
JMS BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up
with different versions on classes on the class path).
The newest version!
package org.jgroups.util;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
/**
* Lists all network interfaces on a system
* @author Bela Ban Dec 18
* @author 2003
*/
public class GetNetworkInterfaces {
public static void main(String[] args) throws SocketException {
Enumeration en=NetworkInterface.getNetworkInterfaces();
while(en.hasMoreElements()) {
NetworkInterface i=en.nextElement();
System.out.println(i.getName() + ':');
System.out.println(" \t" + i.getDisplayName());
for(Enumeration en2=i.getInetAddresses(); en2.hasMoreElements();) {
InetAddress addr=en2.nextElement();
System.out.println(" \t" + addr + " (" + addr.getHostName() + ')');
}
System.out.println("---------------------");
}
}
}