How to get Host name in Java
Hot to get the System name/ Host name/ Machine name in Java?
1 Answer
7 years ago by Divya
String hostName = "UNKNOWN";
try {
hostName = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
System.out.println("Unable to resolve host");
}
System.out.println("HostName is:" + hostName);
7 years ago by Karthik Divi