I'm using a library that uses java.net.InetAddress.getLocalHost().getHostAddress()
to get my local IP address. However, this always returns an IPv6 address on my computer (Gentoo Linux, JDK 1.6.0_37). The address is further used in a context which does not support IPv6 addresses and thus fails.
Is there some way to force getHostAddress()
to return a IPv4 address (e.g. through a parameter to JVM)?