http.keepAlive Java System Property accepts a boolean value to control if HTTP keep alive connections are used.Determines if HTTP keep alive is used when a HTTP or HTTPS request is made via an api provided by the Java SDK (HttpsURLConnection or URL.openStream()).
The http.maxConnections system property determines how many connections are kept alive.
Here are some other networking Java system properties:
http.agenthttp.maxConnectionshttps.protocolsjava.net.preferIPv4Stackjava.net.preferIPv6Addressesjava.net.useSystemProxiesjavax.net.debugjavax.net.ssl.trustStorejdk.net.hosts.filejdk.tls.client.protocolsjdk.tls.disabledAlgorithmsnetworkaddress.cache.negative.ttlnetworkaddress.cache.ttlsun.net.client.defaultConnectTimeoutsun.net.client.defaultReadTimeoutsun.net.inetaddr.ttlJava has supported the http.keepAlive system property since at least version 1.6, support may go back to even older versions of java.
http.keepAlive on StartupYou can set the http.keepAlive java system property during startup of the java runtime using the -D command line argument:
java -Dhttp.keepAlive=true MyAppMain
You may also be able to specify http.keepAlive via the JAVA_TOOL_OPTIONS environment variable:
JAVA_TOOL_OPTIONS=-Dhttp.keepAlive=true
http.keepAlive at RuntimeYou can set http.keepAlive at runtime with the following Java code:
System.setProperty("http.keepAlive", "true");
WARNING: Depending on the property and JVM version using
setPropertymay or may not work if the JDK Java class that uses this variable has already been loaded. The value of the http.keepAlive system property may be cached within an internal private static variable of the implementing class.
To read the value of http.keepAlive at runtime, you can use this Java code:
String propertyValue = System.getProperty("http.keepAlive");
if (propertyValue != null) {
System.out.println("http.keepAlive = " + propertyValue);
} else {
System.out.println("http.keepAlive was null");
}