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.
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:
""), resulting in a zero-length string passed to the process (previously, it was silently ignored).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.
Here are some other Java system properties:
com.sun.jndi.ldap.object.trustSerialDatajava.locale.providersjava.security.propertiesjdk.jar.maxSignatureFileSizejdk.nio.zipfs.allowDotZipEntryjdk.serialFilterJava has supported the jdk.lang.Process.allowAmbiguousCommands system property since Java 8u291, 11.0.11, 16.0.1.
jdk.lang.Process.allowAmbiguousCommands on StartupYou 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
jdk.lang.Process.allowAmbiguousCommands at RuntimeYou 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
setPropertymay 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");
}