This discussion is archived
2 Replies Latest reply: Aug 27, 2012 8:58 AM by qjvictor RSS

Get SocketException when trying to get Mac address.

qjvictor Newbie
Currently Being Moderated
I got SocketException when trying to get mac address from a solaris machine:

JDK: 1.6.26.
Release: 5.10
Kernel architecture: sun4u
Application architecture: sparc
Hardware provider: Oracle Corporation
Domain: Kernel version: SunOS 5.10 Generic_147440-01

java code:
Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();
while (en.hasMoreElements()) {
NetworkInterface intf = en.nextElement();
byte[] mac = intf.getHardwareAddress();

Stacktrace: Invalid argument
     at Method)

Hardware and environment:
The Solaris is on one of four domains on a M5000 server, it has its own set of hardware resources which includes the network interface.
If you run shell script commands like 'arp –a' or '/usr/bin/netstat -pn', it would display correct mac address.
But if you are using Java NetworkInterface.getHardwareAddress() api, it will throw SocketException.

Any suggestion is welcomed.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points