public static String getMacAddress ( ) { try { List < String > macAddress = new ArrayList < String > ( ) ; Enumeration < NetworkInterface > enumNetWorkInterface = NetworkInterface . getNetworkInterfaces ( ) ; while ( enumNetWorkInterface . hasMoreElements ( ) ) { NetworkInterface netWorkInterface = enumNetWorkInterface . nextElement ( ) ; byte [ ] hardwareAddress = netWorkInterface . getHardwareAddress ( ) ; if ( hardwareAddress != null && netWorkInterface . isUp ( ) && ! netWorkInterface . isVirtual ( ) ) { String displayName = netWorkInterface . getDisplayName ( ) . toLowerCase ( ) ; if ( ! displayName . contains ( "virtual" ) && ! displayName . contains ( "tunnel" ) ) { String strMac = "" ; for ( int i = 0 ; i < hardwareAddress . length ; i ++ ) { strMac += String . format ( "%02X%s" , hardwareAddress [ i ] , ( i < hardwareAddress . length - 1 ) ? "-" : "" ) ; } if ( strMac . trim ( ) . length ( ) > 0 ) { macAddress . add ( strMac ) ; } } } } return macAddress . toString ( ) . replace ( "," , ";" ) . replace ( "[" , "" ) . replace ( "]" , "" ) ; } catch ( Exception e ) { throw new JKException ( e ) ; } }
Gets the physical active mac address .