Monday, March 23, 2009

How do I get the hostname of the machine the application is running on?

Use the getHostName() method of the InetAddress class

InetAddress address = InetAddress.getLocalHost();
String hostname = address.getHostName();

No comments: