Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get the server IP, hostname and MAC?

 
Lester Tam
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As title thanks.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see API docs.
 
Lester Tam
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

i find that i can use this way to get the ip and host name:

hostInfo = InetAddress.getLocalHost();
ip = hostInfo.getHostAddress();
hostName = hostInfo.getHostName();

but still dont know how to get the MAC address.

Any help?
Lester
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can't get the MAC address. It's not exposed as you have no business using it.
The network is only concerned with ip addresses except at the hardware level which is deeper in the network architecture than what Java is designed to handle.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic