JDK1.4.2 doesn't return IPV6 address using getHostAddress

389 views Asked by At

JDK 1.5 above returns the IPV6 addresses fine. But JDK1.4.2 returns only IPV4 addresses. The OS are Windows XP and Windows 7. Anyone manages to get the IPV6 addresses on JDK 1.4.2?

    NetworkInterface iface = null;
    for (Enumeration ifaces = NetworkInterface.getNetworkInterfaces(); ifaces
            .hasMoreElements();) {
        iface = (NetworkInterface) ifaces.nextElement();

        InetAddress ia = null;
        for (Enumeration ips = iface.getInetAddresses(); ips
                .hasMoreElements();) {
            ia = (InetAddress) ips.nextElement();
            System.out.println(ia.getHostName());
        }

    }

I am suspicious that there is this native code in java.net.InetAddressImplFactory.

private static native boolean isIPv6Supported();

Since JDK1.4.2 was developed long time ago, it might not be compatible with the native library in Windows to get the IPV6 addresses. Is this correct?

0

There are 0 answers