Controlling network properties
On many operating systems, the default behavior is to use IPv4 instead of IPv6. The following JVM options can be used when executing a Java application to control this behavior. The first setting is as follows:
-Djava.net.preferIPv4Stack=false
This is the default setting. If IPv6 is available, then the application can use either IPv4 or IPv6 hosts. If set to true
, it will use IPv4 hosts. IPv6 hosts will not be used.
The second setting deals with the type of addresses used:
-Djava.net.preferIPv6Addresses=false
This is the default setting. If IPv6 is available, it will prefer IPv4 addresses over IPv6 addresses. This is preferred because it allows backward compatibility for IPv4 services. If set to true
, it will use IPv6 addresses whenever possible.