For OpenJDK 25’s socket implementation, select SOCKS4 with the socksProxyVersion property. It can be supplied when launching the application:

java -DsocksProxyVersion=4 YourApplication

The application can still supply the proxy endpoint explicitly:

Proxy proxy = new Proxy(Proxy.Type.SOCKS,
    new InetSocketAddress("proxy.example", 1080));
try (Socket socket = new Socket(proxy)) {
    socket.connect(new InetSocketAddress("192.0.2.10", 80), 5000);
    socket.setSoTimeout(10000);
}

The addresses are placeholders. An unauthenticated address from the SOCKS4 proxy list can fill the proxy host and port for an allowed public IPv4 test; use the actual target IPv4 address and port separately. This fragment opens and closes the TCP stream; an application protocol would use the connected stream inside the block.

OpenJDK 25’s implementation checks the version property even when the constructor received an ordinary explicit SOCKS Proxy. The public Proxy object itself contains a type and address, not a per-object SOCKS version field.

The version property has JVM-wide scope. If concurrent workloads require different SOCKS versions, do not switch it back and forth around individual requests. Use a client interface that supports the required per-connection selection instead. Private setV4 reflection from old JDK examples is not the supported configuration interface.

Mikanda mikatakata