Recommended way to get hostname in Java
Strictly speaking – you have no choice but calling either hostname(1) or – on Unix gethostname(2). This is the name of your computer. Any attempt to determine the hostname by an IP address like this InetAddress.getLocalHost().getHostName() is bound to fail in some circumstances: The IP address might not resolve into any name. Bad DNS setup, … Read more