Java System Properties
Quick Reference Guide


sun.net.client.defaultReadTimeout Java System Property

The sun.net.client.defaultReadTimeout Java System Property accepts an integer value representing the number of milliseconds

Default Value

-1

sun.net.client.defaultReadTimeout Overview

This property specifies the the default connect timeout (in milliseconds) for the protocol handler used by java.net.URLConnection.

The value of -1 means that it will wait indefinitely, there is no timeout.

This does not control the read timeout of all Sockets, only those used by java.net.URLConnection.

Related System Properties

The sun.net.client.defaultConnectTimeout system property is related to the sun.net.client.defaultReadTimeout property, it represents how long it will wait a host connection.

Here are some other networking Java system properties:

Supported Since

Java has supported the sun.net.client.defaultReadTimeout system property since at least version 6, support may go back to even older versions of java.

Setting sun.net.client.defaultReadTimeout on Startup

You can set the sun.net.client.defaultReadTimeout java system property during startup of the java runtime using the -D command line argument:

java -Dsun.net.client.defaultReadTimeout=-1 MyAppMain

You may also be able to specify sun.net.client.defaultReadTimeout via the JAVA_TOOL_OPTIONS environment variable:

JAVA_TOOL_OPTIONS=-Dsun.net.client.defaultReadTimeout=-1

Setting / Reading sun.net.client.defaultReadTimeout at Runtime

You can set sun.net.client.defaultReadTimeout at runtime with the following Java code:

System.setProperty("sun.net.client.defaultReadTimeout", "-1");

WARNING: Depending on the property and JVM version using setProperty may or may not work if the JDK Java class that uses this variable has already been loaded. The value of the sun.net.client.defaultReadTimeout system property may be cached within an internal private static variable of the implementing class.

To read the value of sun.net.client.defaultReadTimeout at runtime, you can use this Java code:

String propertyValue = System.getProperty("sun.net.client.defaultReadTimeout");
if (propertyValue != null) {
    System.out.println("sun.net.client.defaultReadTimeout = " + propertyValue);
} else {
    System.out.println("sun.net.client.defaultReadTimeout was null");
}