Here you can find the source of getLocalShortHostName()
public static String getLocalShortHostName()
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; public class Main { private static String cachedShortHostName = null; public static String getLocalShortHostName() { if (cachedShortHostName != null) { return cachedShortHostName; }//from ww w.j a va2s. c o m try { String hostName; InetAddress iAddress = InetAddress.getLocalHost(); hostName = iAddress.getHostName(); // String canonicalHostName = iAddress.getCanonicalHostName(); String[] parts = hostName.split("\\."); hostName = parts[0]; cachedShortHostName = hostName; return cachedShortHostName; } catch (Exception e) { return e.getMessage(); } } }