In a .properties
file I store the local network interface (i.e. MAC address) which I want to be used by my Java application. Then I get that information as a property.
Now I want to get the local IP address currently associated to this MAC address. How could I do that with Java?
Note that I can't use Reverse ARP on a gateway. I don't have any gateway, I work locally only.
Thanks.
You can use NetworkInterface for this (http://docs.oracle.com/javase/6/docs/api/java/net/NetworkInterface.html):
Enumeration<NetworkInterface> interfaces =
NetworkInterface.getNetworkInterfaces();
while (interfaces.hasMoreElements()) {
NetworkInterface i = interfaces.nextElement();
if ( i.getHardwareAddress().... ) {
}
}