/******************************************************************************/ // Print the hostname and IP address of the local machine from which this // program is run. // // Roy Vanegas: rvanegas@hunter.cuny.edu /******************************************************************************/ import java.net.*; public class DisplayLocalHostAndIPAddress { public static void main( String[] args ) { try { InetAddress thisMachine = InetAddress.getLocalHost(); System.out.println( "The host name/IP address of this machine: \n\t" + thisMachine ); } catch( UnknownHostException uhe ) { uhe.printStackTrace(); } } }