I\'ve been getting hostname of the machine as follows:
InetAddress.getLocalHost().getHostName();
However, when I put latest JDK (jdk1.7.0_04),
This is a known issue in the macosx port of JDK7u4.
http://java.net/jira/browse/MACOSX_PORT-564