Possible Duplicate:
Query ARP cache to get MAC ID
I need to get the mac addresses of all the remote machines connected to my home network. i can read the mac address of my own machine using this code below but i don't know how to get the mac addresses of other machines on my network. or is it possible or not.
import java.net.InetAddress;
import java.net.NetworkInterface;
class Test {
public static void main(String[] args) throws Exception {
InetAddress address = InetAddress.getLocalHost();
NetworkInterface ni = NetworkInterface.getByInetAddress(address);
byte[] mac = ni.getHardwareAddress();
for (int i = 0; i < mac.length; i++) {
System.out.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "");
}
}
}
output (MyComputer's 6byte mac address)
30-60-77-12-cd-99