Here you can find the source of getShortHostName()
public static String getShortHostName()
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { /**/* w ww . j a v a 2 s . c o m*/ * get the current host name * * @return String host name */ public static String getShortHostName() { String hostname = null; try { hostname = InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { // TODO Auto-generated catch block e.printStackTrace(); } return hostname; } }