Here you can find the source of getHostName()
@Deprecated public static String getHostName()
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { @Deprecated public static String getHostName() { try {//w w w . ja va 2s. com InetAddress.getLocalHost().getHostName(); return "0.0.0.0"; } catch (UnknownHostException e) { e.printStackTrace(); return "127.0.0.1"; } } }