import java.net.*; public class Test2 { public static void main(final String [] pArgs) throws Exception { for (final InetAddress addr : InetAddress.getAllByName("localhost")) { System.out.println("canonical: " + addr.getCanonicalHostName() + " - addr: " + addr.getHostAddress() + " - name: " + addr.getHostName()); } final InetAddress localAddr = InetAddress.getLocalHost(); System.out.println("local canonical: " + localAddr.getCanonicalHostName() + " - local addr: " + localAddr.getHostAddress() + " - local name: " + localAddr.getHostName()); } }