How do I get the physical addresses of my machine in Java.
Do you mean a memory address, the IP address(es) or the MAC address(es)?
try {
InetAddress addr = InetAddress.getLocalHost();
// Get IP Address
byte[] ipAddr = addr.getAddress();
// Get hostname
String hostname = addr.getHostName();
} catch (UnknownHostException e) {
}
I think this might be what you're looking for, in the Java API for the InetAddress class: http://java.sun.com/javase/6/docs/api/java/net/InetAddress.html
getLocalHost()
As of Java 6, java.net.NetworkInterface class now has the method getHardwareAddress()
http://java.sun.com/javase/6/docs/api/java/net/NetworkInterface.html#getHardwareAddress()
If that's too new, there are UUID packages which try various methods per OS to ask for it. Try e.g. http://johannburkard.de/blog/programming/java/MAC-address-lookup-using-Java.html
If you need you need the MAC address you are going to require JNI. I use a library called JUG to generate UUIDs based using the real MAC address of the machine. You can consult their source code to see how this is accomplished on Linux, Solaris, Windows and Mac platforms.