wood burning stoves*
The moose likes Java in General and the fly likes Reading MAC address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Reading MAC address" Watch "Reading MAC address" New topic
Author

Reading MAC address

satya sahu
Ranch Hand

Joined: Mar 26, 2003
Posts: 97
Hi all,
Is there any way to read MAC address of the ethernet card. My requirement is to enable & disable the ethernet card programatically. If java does not support then some C code and JNI will also solve my problem.
Please give me some solution.
Stuart Gray
Ranch Hand

Joined: Apr 21, 2005
Posts: 410
In pure Java - impossible. Another language (C and Windows API?) and JNI are the way to go here without a doubt.
Mark Wuest
Ranch Hand

Joined: Jun 07, 2003
Posts: 88
You can run an external program and parse the output.

In Linux, the program is "/sbin/ifconfig <interface>" - the number after HWaddr is the MAC address. e.g.:

In the example above, 00:0A:E6:CF:ED:B4 is the MAC address.

In Windows, the command is "ipconfig /all" and the line with Physical Address in it has your MAC address. The line will look somewhat like this:


You'd run it like this in Linux:

then read and parse 'in' for your answer.

Mark
[ June 04, 2005: Message edited by: Mark Wuest ]
Steven Bell
Ranch Hand

Joined: Dec 29, 2004
Posts: 1071
Keep in mind it is possible for a computer to have more than one MAC address.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

And possible to fake MAC-Adresses.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading MAC address
 
Similar Threads
I have no IP address!
How to connect internet on RHEL 5.1?
Bodgitt & Scarper 2.2.3 (Identifying the Client using MAC Address).
Copy Protection
How to lock java app for single PC