DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Douglas has posted 12 posts at DZone. View Full User Profile

Get Your Machine's MAC Address

06.25.2009
| 3791 views |
  • submit to reddit
        // Only gets the address for the first net interface, if you have more than one you'll need to get the list
// and decide which you want to use.

    InetAddress add = InetAddress.getLocalHost();
    NetworkInterface ni = NetworkInterface.getByInetAddress( add );
    byte[] mac = ni.getHardwareAddress();