Using Windows XP+ (7, 8, etc) the file paths can have embedded spaces.
This must be processed correctly because the various product installers including Windows its self builds just such paths.
Therefore using paths without embedded spaces is NOT possible, to belay comments about just change path names.
Further, some tools require that their command line arguments use these paths.
A common type of command line argument (single quotes are my addition) might be '-I"C:\Program Files (x86)\Product\Library"'
The "s in the command line argument are required for the Windows command processor to correctly parse the command which is standard with Windows.
All solutions I found recommended on the web for processing the spaces in the path name fail with the above argument because of the use of both embedded spaces and "s.
I have found various references on the web identifying this specific problem of
Java, ProcessBuilder, and Windows.
I have build simple
test programs to test various options and as of yet have not found any solution.
I have escaped the "s, escaped the \s, and various combinations.
None work nor does any solution I have found on the web.
What is particularly annoying about this, is that I can pass correctly a space embedded file name/directory name but not pass a command line argument of the for -I"C:\Pro ..... mentioned above.
Example of file name path that works successfully (double \\ required by Java):
"C:\\Software Development\\MyTesting\\VS2008\\CPP\\EchoCommandLineArguments\\Debug\\EchoCommandLineArguments.exe"
Which ProcessBuilder builds process request as
C:\Software Development\MyTesting\VS2008\CPP\EchoCommandLineArguments\Debug\EchoCommandLineArguments.exe"
For the curious, EchoCommandLineArguments.exe is a quick and dirty C++ executable the echos its command line arguments.
If I go to a windows command prompt, I can type the command and arguments as required, specifically, -I"C:\Program Files (x86)\Product\Library"
Is there a solution? Or is Java not a full production environment?
I am using the following Windows 7 version 6.1, Netbeans
IDE 7.4 (Build 201310111528), Java 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08, and Runtime Java(TM) SE Runtime Environment 1.7.0_45-b18.
I have additionally been unsuccessful using the Process.exec method.
Thanks in advance,
Pat