Semi-broken IPv6 in Java

I tried to get Tomcat and JBoss running on FreeBSD 5.3-BETA7. Tomcat would exit after a few seconds and JBoss would run but not listen on any TCP/IP sockets. After being annoyed a little while I remembered a thread on the OpenBSD Java mailinglist about the weird IPv6 support in Java.

The problem is that if Java is compiled with -DWITH_IPV6 it always creates an AF_INET6 socket as Otto Moerbeek explained. So, if embedded IPv4 addresses are available everything is fine, if not, Java can't talk to IPv4 hosts. I guess it works on Solaris, perhaps even Windows and Linux, but not on BSD.

So I recompiled …/java/jdk14 without -DWITH_IPV6 and voila!, it worked. It's just irritating to have the computer compiling for just over 9½ hours for that, plus 3½ hours for Eclipse which, now that FreeBSD has changed to GCC 3.4.2 as system compiler, also depended on the GCC 3.3.5 port.

Amazingly, searching for “IPv6” on returns nothing.