Unique Identifier for a server

In order to get a unique machine identifier I have used

hostName = InetAddress.getLocalHost().getHostName();
return Math.abs(Long.valueOf(hostName.hashCode()));

Which works but it a bit clumsy.  Should really look for a better way.

A trivial way of acheiving the same things would be to get the IP address and removed the dots so = 133231212123.

Otherwise it is possible to to convert it to a decimal http://www.mkyong.com/java/java-convert-ip-address-to-decimal-number/