Here you can find the source of getHost()
public static String getHost()
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { /**/*ww w.j a va 2 s. co m*/ * Gets the hostname of the machine running the code, foregoing the need for exception handling * in-line when this information is needed. * * @return The hostname of the machine */ public static String getHost() { String host = "unknown"; try { host = InetAddress.getLocalHost().getHostName(); } catch (final UnknownHostException ex) { ex.printStackTrace(); } return host; } }