if (hostname.equals("")) {
try {
Enumeration e = NetworkInterface.getNetworkInterfaces();
while (e.hasMoreElements() && hostname == null) {
NetworkInterface netface = (NetworkInterface) e.nextElement();
Enumeration e2 = netface.getInetAddresses();
while (e2.hasMoreElements() && hostname == null) {
InetAddress ip = (InetAddress) e2.nextElement();
if (!ip.getCanonicalHostName().equals("localhost")
&& !ip.getCanonicalHostName().equals("localhost.localdomain")) {
hostname = ip.getCanonicalHostName();