Here you can find the source of getLocalCanonicalHostName()
public static String getLocalCanonicalHostName() throws UnknownHostException
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static String getLocalCanonicalHostName() throws UnknownHostException { InetAddress localMachine = InetAddress.getLocalHost(); return localMachine.getCanonicalHostName(); }/*from ww w . j av a 2s . co m*/ }