title: Java - Getting MAC address of Linux system
body: <p>I'm trying to get the MAC address of a linux system with this code:</p>
  
  <pre><code>try {
    ip = InetAddress.getLocalHost();
    NetworkInterface network = NetworkInterface.getByInetAddress(ip);
    byte[] mac = network.getHardwareAddress();
    // System.out.print("Current MAC address: ");
    for (int i = 0; i &lt; mac.length; i++) {
      is = is + Integer.parseInt(
        String.format("%02X%s", mac[i], (i &lt; mac.length - 1) ? "" : ""),16);
    }
  } catch (UnknownHostException e) {
    e.printStackTrace();
  } catch (SocketException e) {
    e.printStackTrace();
  }
  </code></pre>
  
  <p>But it just crashes... does anyone know why?</p>