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 ...

Get Learning Network Programming with Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.