public class GetComputerName {
public static void main(String args[]) {
try {
String computerName = InetAddress.getLocalHost().getHostName();
System.out.println(computerName);
} catch (Exception e) {
System.out.println("Exception caught =" + e.getMessage());
}
}
}