Java tutorial
//package com.java2s; import java.net.InetAddress; import java.net.NetworkInterface; public class Main { public static String getMACAdress() { InetAddress ip; try { ip = InetAddress.getLocalHost(); NetworkInterface network = NetworkInterface.getByInetAddress(ip); byte[] mac = network.getHardwareAddress(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < mac.length; i++) { sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "")); } return sb.toString(); } catch (Exception e) { return null; } } }