title: How to get remote machines mac addresses java
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1238963/query-arp-cache-to-get-mac-id">Query ARP cache to get MAC ID</a>  </p>
  </blockquote>
  
  
  
  <p>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.</p>
  
  <pre><code>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 &lt; mac.length; i++) {
    System.out.format("%02X%s", mac[i], (i &lt; mac.length - 1) ? "-" : "");
  }
  }
  }  
  </code></pre>
  
  <p>output  (MyComputer's 6byte mac address)<br>
  30-60-77-12-cd-99   </p>