简体   繁体   中英

How to fetch MAC Address from client machine in JAVA?

I am creating an website for that I need to fetch client's MAC address to identify the client. I have tried with the applets, but it was not fruitful. Please help.

Using NetworkInterface only is an incomplete answer. It would work if the goal was to get the SERVERS mac-address. The poster clearly states that he wants the CLIENTS mac-address.

The way to accomplish this is either through an applet or through an ActiveX plugin component (which is not guaranteed to work outside IE).

The problem here (that you have already encountered) is that this operation (NetworkInterface) is protected in a regular applet and not allowed by the security manager. To do it, you would have to sign your applet and include a policy-file allowing the applet to access the clients system (ie the NetworkInterface class).

NetworkInterface ni = NetworkInterface.getByInetAddress(address);
if (ni != null) 
byte[] mac = ni.getHardwareAddress();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM