Get the MAC Address with Java
I recently needed to get the MAC address from staff workstations as a means of uniquely identifying which remove office the PC resided in. Network IP was not reliable because multiple offices share the same router. Cookies weren’t good enough because systems get wiped each night in an automated process to maintain a static workstation image. That left either reconfiguring the networks at multiple locations, or to find a unique identifyer on each system that persists. Here’s to the MAC address which is unique to each network adapter.
So, to do this qould require I use some kind of deployable application that can access the local system. As I searched around, it appeared Java was a good option but I haven’t used Java outside school. Luckily, I stumbed across Tim Desjardins’ blog entry on the topic. He had written a java applet to do this very task.
I ran into one oddity with Windows Vista. It will produce multiple MAC addresses (for loopback adapters and such) and some will actually contain only spaces. I used Javascript to clean up the results and got a working demo here:
http://brad.melendy.com/projects/java/macAddress.cfm
You will be prompted to allow the applet to run on your system through a browser security warning. Once you give consent, the button will display one or more of your MAC addresses in a Javascript alert. I am capturing this information into a database as a unique identifier for each workstation. I actually store it in a cookie for the duration of the day, but each morning I collect it anew as staff/visitors enter a particular system.
Comments(0)