Here you can find the source of getMACAddress()
public static String getMACAddress()
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; public class Main { private static InetAddress ip; public static String getMACAddress() { StringBuilder sb = new StringBuilder(); try {//from w ww . ja v a 2 s . c om NetworkInterface network = NetworkInterface .getByInetAddress(ip); byte[] mac = network.getHardwareAddress(); for (int i = 0; i < mac.length; i++) { sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "")); } } catch (SocketException e) { e.printStackTrace(); } return sb.toString(); } }