1

I have updated my question after receiving suggestion about SSCCE. Here it is again:

I am trying to execute following code with ProcessBuilder using JDK7u21:

List<String> cmd = new ArrayList<String>(Arrays.asList(cmdLine));
if (addMetaInfo)
    System.out.println("Executing command '" + cmd + "' on OS '" + System.getProperty("os.name") + "'");
try {
    ProcessBuilder pb = new ProcessBuilder(cmd);
    pb.directory(workingDir);
    proc = pb.start();
} catch (IOException e) {
    System.out.println(e.getMessage());
    throw e;
}

After executing above code I get this:

Executing command '[C:\MyCLI.cmd, -c, C:\myFile.etl, -d, DateConverter, -l"ERROR", -p"[INPUT1]=2010:06:18", -p"[INPUT2]=2010:06:19"]' on OS 'Windows 7'
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Argument has embedded quote, use the explicit CMD.EXE call.

I also tried escaping the double-quotes after -l and -p arguments while supplying the input but it doesn't work either.

Saw ProcessBuilder adds extra quotes to command line already, but no clue.

Can someone please help?

Community
  • 1
  • 1
ParagJ
  • 1,566
  • 10
  • 38
  • 56

0 Answers0