Here you can find the source of getCurrentHost()
public static String getCurrentHost()
//package com.java2s; /**//from w w w .j a v a 2 s . c o m * Taken from apache hadoop project. * Apache 2.0 license. * * @param className * @return */ import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static String getCurrentHost() { String hostname = "localhost"; try { hostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { e.printStackTrace(); } return hostname; } }