// An application to find out the current address and DNS name
// of the local computer - Derek Molloy.

import java.net.*;

public class NetApp1
{
  public static void main(String args[])
  {
    try	// try to do the following
    {
        InetAddress localaddr = InetAddress.getLocalHost();	// get local address
        String hostName = localaddr.getHostName();			// find the dns name
        System.out.println ("Local IP Address : " + localaddr);
        System.out.println ("Local hostname : " + hostName);
    }
    catch (UnknownHostException e)	// catch the unknown host exception
    {
        System.err.println ("Can't detect localhost : " + e);
    }                
  }
}