title: ProcessBuilder not executing Java class file properly
body: <p>In a java file I am calling command line statement to execute another java file. This is what I am doing:</p>
  
  <pre><code>List&lt;String&gt; paramsExecute = new ArrayList&lt;String&gt;();
  paramsExecute.add("java");
  paramsExecute.add("-cp");
  paramsExecute.add("input\programs\User_K Program1");
  paramsExecute.add("1 2 3");
  
  ProcessBuilder builderExecute = new ProcessBuilder(paramsExecute);
  
  builderExecute.redirectOutput(new File(a.txt));
  builderExecute.redirectError(new File(b.txt));
  </code></pre>
  
  <p>Execution of one of the Java files is producing b.txt as:</p>
  
  <pre><code>Error: Could not find or load main class 1 2 3
  </code></pre>
  
  <p>Another java file is producing b.txt as:</p>
  
  <pre><code>Usage: java [-options] class [args...] ...
  </code></pre>
  
  <p>But, when I am running these statements directly from the command line, it is executing correctly. The folder <code>input\programs\</code> is in the same path as the <code>src</code> folder. The <code>src</code> folder contains the Java file containing the ProcessBuilder program. I have verified that the .class file is getting created correctly and in the right folder. I am running the program in windows. </p>
  
  <p>Any help appreciated!!</p>