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?
[sourcecode language=”java”]
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);
}
}
}
[/sourcecode]
Note : This code will return only the first net address; if you need other detils too, get a list.
Posted from WordPress for Android
System.out.println on a byte[] won’t give you useful output…
🙂
Hi,
Awesome blog.
If you could indent your code it would be much more readable.
Thanks.
But I would suggest you to change your name!
good to see blog like this.. thanks for sharing.. 🙂
Welcome About
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…
Oh, really.
Thanks JavaPins for sharing this post on to your site.