Here you can find the source of getHostName()
public static String getHostName()
//package com.java2s; /*//from w w w .ja v a2 s . com Pulsar Copyright (C) 2013-2015 eBay Software Foundation Licensed under the GPL v2 license. See LICENSE for full terms. */ public class Main { public static String getHostName() { String host = "unknownhost"; try { host = java.net.InetAddress.getLocalHost().getHostName(); } catch (java.net.UnknownHostException e) { } return host; } }