• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NIC ADDRESS

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to get NIC(Network Interface Card) Address using java 2.0. Do u have any idea how to get the NIC address
of an machine.
Thanks,
Swami
 
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you could arrange the execution of the ipconfig dos command and capture its output? When you use "ipconfig /all" it provides the NIC address. When you use "ipconfig /all >x.txt" it puts the output into x.txt which you could read with your java program. Maybe someone else has some idea on how to run a dos program from java???
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@see java.net.NetworkInterface
Why are some developers so intent on running a system command to achieve something ? *especially* when the core API provides the desired behaviour.
*shakes head in disbelief*
 
Eddie Vanda
Ranch Hand
Posts: 283
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure whether to hang my head in shame or not, but I do not see any thing about NIC addresses in that class, only IP details. But I am certainly not an expert in that area. My impression is that java isolates you from all that low level stuff.
 
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, here's some code showing you how to get the NIC cards and some of their info, BUT, I couldn't find out how to get the NIC Cards' physical addresses.

How do I get the physical address? For example, an address like: 00-EE-AA-BB-00-00 (I made it up, but you get the idea). I don't see any place where I can obtain that.
[ February 26, 2004: Message edited by: Robert Paris ]
 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've got some code that works on Windows, OS X and Linux, but they're all just parsing "ifconfig" from Runtime.exec(). Is there really no other way to do this? I have written C code on Windows to grab the Mac Address, but MS helpfully made those APIs different on almost every Windows version (i.e. what works on 98 won't on 2000, etc). Further, I'm not sure that Linux or Unix or OS X have system APIs available for that - I think the only way to get a NIC's address on those OS's is from ifconfig.
Is this really true? Is there no other way? Why is it so "ugly" to get that info in Java (or any language apparently)?
Does anyone have code for getting MAC address on Unix, Solaris? How would I know it was Unix? (i.e. what would System.getProperty( "os.name" ) return?)
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about a call to the system ARP server? You'll have to use some native code to get to OSI Layer 2 since Java only deals with layers 3 & 4.
Tom Blough
[ February 26, 2004: Message edited by: Tom Blough ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic