class NetworkUtil {

    public static String getLocalHostname() {
        InetAddress address;
        String hostname;
        try {
            address = InetAddress.getLocalHost();
            // force a best effort reverse DNS lookup
            hostname = address.getHostName();
            if (StringUtil.isEmpty(hostname)) {
                hostname = address.toString();
            }
        } catch (UnknownHostException noIpAddrException) {
            hostname = LOCALHOST;
        }
        return hostname;
    }

}