2 Replies Latest reply on Aug 27, 2012 3:58 PM by qjvictor

    Get SocketException when trying to get Mac address.

      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();

      java.net.SocketException: Invalid argument
           at java.net.NetworkInterface.getMacAddr0(Native Method)
           at java.net.NetworkInterface.getHardwareAddress(NetworkInterface.java:385)

      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.