how to force a java jvm to listen on ipv4 instead of ipv6

nowadays, when launching a java app that creates a listening socket, it often defaults to listening to ipv6 exclusively. that would be great, but many current OS’s include a lot of code that only _ sort of _ support ipv6. for instance, notice the * + +* address in the following output from netstat on a linux box:

# netstat -pant | grep 8080
tcp6   0   0     :::*     LISTEN      24737/java


sometimes it’s quickest to simply force ipv4. if one has access to the code being run, add:

+ System.setProperty("", "true"); +

if not, when launching from the command line, try adding this parameter:

+ +