title: Runtime.getRuntime().exec Hangs
body: <p>I have a java jar file which inturn calls a java program (command).</p>
  
  <p>Command generated works fine when i run it in command promt.</p>
  
  <pre><code>Process proc = Runtime.getRuntime().exec("cmd.exe /C "+ Command);
  
          BufferedReader stdIn = new BufferedReader(new 
                       InputStreamReader(process.getInputStream()));
  
                  BufferedReader stdErr = new BufferedReader(new 
                       InputStreamReader(process.getErrorStream()));
  
              String output=null;
              while((output=stdIn.readLine())!=null)
              {
                  System.out.println("output is:"+output);
                  out.write(output);
                  out.newLine();
  
              }
              while((output=stdErr.readLine())!=null)
              {
                  System.out.println("error output is:"+output);
                  out.write(output);
                  out.newLine();
  
              } 
              try {
  process.waitFor();
  ....
  ....
  ....
  </code></pre>
  
  <p>I tried ProcessBuilder:</p>
  
  <pre><code>ProcessBuilder proc = new ProcessBuilder("cmd.exe", "/C", Command);         proc.redirectErrorStream(true);
  proc.start();
  </code></pre>
  
  <p>But this throws error as:</p>
  
  <pre><code>java.io.IOException: Cannot run program "java -Xmx1024M ......"
  CreateProcess error=2, The system cannot find the file specified
  </code></pre>
  
  <p>I can run the same command in promt which works absolutely fine.</p>