Get MAC Address using Java
Posted June 11, 2012
on:Objective :
* How to get the MAC Address of a computer?
* How to get the MAC Address of a computer using Java?
* How to get the MAC Address of a computer via programming?
import java.net.*; class GetMac { public static void main(String arg[]) { try { InetAddress address = InetAddress.getLocalHost(); NetworkInterface nwi = NetworkInterface.getByInetAddress(address); byte mac[] = nwi.getHardwareAddress(); System.out.println(mac); } catch(Exception e) { System.out.println(e); } } }
Note : This code will return only the first net address; if you need other detils too, get a list.
Posted from WordPress for Android
10 Responses to "Get MAC Address using Java"

Get MAC Address using Java…
Thank you for submitting this cool story – Trackback from JavaPins…
LikeLike

January 17, 2013 at 5:17 AM
not run in divices with more than one ethernet driver. sample: ethernet0 local address and wireless network.
El codigo no funciona en equipos con mas de un driver de red. O sea, si el dispositivo tiene red inalambrica y red lan, si alguno de ellos no esta coenctado no funcionara en la mayoria de los casos, para eso se debe buscar cual de ellos es el que necesita y obtener la direccion mac de ahi… suerte…
LikeLike
January 18, 2013 at 3:27 PM
Oh, really.
LikeLike