Get MAC address in Java

Source: Internet
Author: User

 

Basically, there is no Java-only API to access hardware information. Maybe in the future, who knows?

The requirement for MAC addresses comes from UUID and a large part from license management. This is really a boring thing. I hope the software will sell services in the future, instead of copying them, saving me the trouble.

 

I searched for three types of solutions.

1, JDK 6, JDK 7?

See the following link http://bugs.sun.com/bugdatabase/view_bug.do for details? Bug_id = 4691932

2, shell command

Is to intercept the output of commands such as ipconfig and ifconfig, and then parse

There are some open source projects like http://sourceforge.net/projects/javanetcomm/

There are a lot of code snippets like http://forum.java.sun.com/thread.jspa? Threadid = 61556, http://forum.java.sun.com/thread.jspa? Threadid = 245711

The disadvantage of this method is that it may require high system permissions to execute these commands or access the NIC hardware.

3, JNI

There are also open source projects that include this feature, such as http://jug.safehaus.org/

The disadvantage is that deployment is not convenient.

 

However, not all networks are Ethernet. For License Management, MAC addresses are only a consideration for the concept of "host ID.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.