The Java development environment and language originally developed by Sun Microsystems, Inc. is inherently Internet Protocol (IP) agnostic, beginning with good support for Solaris and limited support for Linux in version 1.4.2, and limited support for Windows XP SP1 (or later versions of Microsoft operating systems) in version 1.5. Documentation for the Java Development Kit (JDK) 19 is available here. See Oracle's earlier Networking IPv6 User Guide for JDK 8 and their Networking Properties for JDK 19 for additional details.
Improved support for IPv6, including multicast, was added in JDK 7.
Packages supplied as part of Java, such as java.io and java.net, support both IP version 4 (IPv4) and IPv6 natively.
Because of the limited support provided by early versions of Java, a few developers “turned off” IPv6 support in their Java apps. To re-enable IPv6 support in such an older app, some java system properties need to be changed. First, make sure that the following properties are set to these values:
-Djava.net.preferIPv4Addresses=false
and
-Djava.net.preferIPv6Addresses=false
If this does not enable the desired IPv6 access, then set
-Djava.net.preferIPv6Stack=true
although this will “turn off” IPv4 support altogether!
To enable IPv4 (only) access, set
-Djava.net.preferIPv4Stack=true