I can use
ip = InetAddress.getLocalHost();
NetworkInterface.getByInetAddress(ip);
to obtain the mac address, but if I use this code in an offline machine it doesn’t work.
So, How can I get the Mac address?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
With Java 6+, you can use
NetworkInterface.getHardwareAddress.Bear in mind that a computer can have no network cards, especially if it’s embedded or virtual. It can also have more than one. You can get a list of all network cards with
NetworkInterface.getNetworkInterfaces().