Possible Duplicate:
How to get a unique computer identifier in Java (like disk id or motherboard id)
Need to identify local machine somehow in java
I want to get some sort of unique ID for the computer (ie IP address).
I have tried:
InetAddress inetAddress = null;
try {
inetAddress = InetAddress.getLocalHost();
} catch (final UnknownHostException ex) {}
return inetAddress.getHostAddress();
This gives an IP, but this one seems to change periodically. Is there a way to get one the DOES NOT change?
Thanks in advance!
NOTE:
I need to be able to associate this ID with the computer.
If the machine is on DHCP, the IP address will change periodically. You could use the hostname, or you could use the MAC address, which you can get with java.net.NetworkInterface.getHardwareAddress()