Java.io package provides methods that can get the local machine name and address. Review the code below:

Java Code:
try {
      InetAddress address = InetAddress.getLocalHost( );
      System.out.println(address);
    }
    catch (UnknownHostException ex) {
      System.out.println("Could not find this computer's address.");
    }
Output:
Java Code:
javapc/127.0.0.1