Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > Ethernet address using JNI (Java Native Interface)

Ethernet address using JNI (Java Native Interface)
Thread Tools
Fresh-Faced Recruit
Join Date: Dec 2003
Status: Offline
Reply With Quote
Dec 3, 2003, 12:49 AM
 
Hi All
I want to find the ethernet address or modem address on IMac Poper PC G3 using the JNI (Java Native interface.). Can some one help me to find the ethernet address or any suggations.

Thanks
VN
(Last edited by biosoft_indore; Dec 3, 2003 at 12:55 AM. )
     
Dedicated MacNNer
Join Date: Nov 2003
Location: SoCal
Status: Offline
Reply With Quote
Dec 3, 2003, 03:00 AM
 
curious, JNI is usually used to wrap native interfaces to things written in C, but you can simply get the host address in java doing:

try {
InetAddress addr = InetAddress.getLocalHost();

// Get IP Address
byte[] ipAddr = addr.getAddress();

// Get hostname
String hostname = addr.getHostName();
} catch (UnknownHostException e) {
}

http://javaalmanac.com/egs/java.net/Local.html
     
Fresh-Faced Recruit
Join Date: Dec 2003
Status: Offline
Reply With Quote
Dec 4, 2003, 04:08 AM
 
Hi
I want to get the ethernet address of the MAC to uniquely identify the IMAC, I don't want to get the localhost address.
Vishal
     
Dedicated MacNNer
Join Date: Nov 2003
Location: SoCal
Status: Offline
Reply With Quote
Dec 4, 2003, 03:00 PM
 
my bad...
I would perhaps suggest a system call to ifconfig or netstat and parse the results.

Sorry to bother.
     
Mac Elite
Join Date: Dec 2001
Location: Atlanta, GA, USA
Status: Offline
Reply With Quote
Dec 5, 2003, 09:42 AM
 
It's ugly, but here's some code that works:

http://forum.java.sun.com/thread.jsp...;thread=245711
Mac Pro 2x 2.66 GHz Dual core, Apple TV 160GB, two Windows XP PCs
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:54 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2