- Below program explains how to get System details like, system name/hostname, IP Address and Login User Name.
package in.malliktalksjava; import java.net.InetAddress; import java.net.UnknownHostException; /** * @author malliktalksjava.in * * This class gives you the system Host details, IP address and * login user name */ public class GetSystemInfo { public static void main(String[] args) { try { InetAddress inetAddress = InetAddress.getLocalHost(); // Print Host Name System.out.println("System Host Name : " + inetAddress.getHostName()); // Print complete hostname with domain System.out.println("System Canonical Host Name : " + inetAddress.getCanonicalHostName()); // print IP address System.out.println("System IP Address : " + inetAddress.getHostAddress()); // Print Login user name System.out.println("Login User : " + System.getProperty("user.login")); } catch (UnknownHostException e) { e.printStackTrace(); } } }