Java System Properties
Quick Reference Guide


jdk.lang.Process.allowAmbiguousCommands Java System Property

The jdk.lang.Process.allowAmbiguousCommands java system property controls how ProcessBuilder handles double-quote encoding in command arguments on Windows.

Default Value

true

If left unset, the behavior is the same as setting it to true (existing behavior is preserved). When a SecurityManager is set, double-quotes are always properly encoded regardless of this property.

Overview of jdk.lang.Process.allowAmbiguousCommands

The jdk.lang.Process.allowAmbiguousCommands system property applies to the java.lang.ProcessBuilder implementation on Windows.

When set to false, the property ensures that for each argument, double quotes are properly encoded in the command string passed to the Windows CreateProcess API:

When set to true (or left unset), the existing behavior is preserved.

Note: This property only affects Windows. It has no effect on other platforms.

Related System Properties

Here are some other Java system properties:

Supported Since

Java has supported the jdk.lang.Process.allowAmbiguousCommands system property since Java 8u291, 11.0.11, 16.0.1.

Setting jdk.lang.Process.allowAmbiguousCommands on Startup

You can set the jdk.lang.Process.allowAmbiguousCommands java system property during startup of the java runtime using the -D command line argument:

java -Djdk.lang.Process.allowAmbiguousCommands=false MyAppMain

You may also be able to specify jdk.lang.Process.allowAmbiguousCommands via the JAVA_TOOL_OPTIONS environment variable:

JAVA_TOOL_OPTIONS=-Djdk.lang.Process.allowAmbiguousCommands=false

Setting / Reading jdk.lang.Process.allowAmbiguousCommands at Runtime

You can set jdk.lang.Process.allowAmbiguousCommands at runtime with the following Java code:

System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false");

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 jdk.lang.Process.allowAmbiguousCommands system property may be cached within an internal private static variable of the implementing class.

To read the value of jdk.lang.Process.allowAmbiguousCommands at runtime, you can use this Java code:

String propertyValue = System.getProperty("jdk.lang.Process.allowAmbiguousCommands");
if (propertyValue != null) {
    System.out.println("jdk.lang.Process.allowAmbiguousCommands = " + propertyValue);
} else {
    System.out.println("jdk.lang.Process.allowAmbiguousCommands was null");
}