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/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s