title: How to make a java program to print both out.println() and err.println() statements?
body: <p>I have written the java code below, which executes another java program named "Newsworthy_RB".</p>
  
  <p>Newsworthy_RB.java contains both the System.out.printlln() and System.err.println() statements.</p>
  
  <p>I want both the outputs to be printed in the command prompt console.</p>
  
  <p>What has to be done inorder to obtain the same.</p>
  
  <p>The below program just prints the out.println() statements and not the err.println() statements.</p>
  
  <p>Kindly let me know whether the code below will function as i expect?</p>
  
  <pre><code>command = "java -cp .:../sqljdbc.jar SetHash Newsworthy_RB";
  Process child1 = Runtime.getRuntime().exec(command);
  InputStream in1 = child1.getErrorStream();
  InputStream in2 = child2.getInputStream();
  while ((c = in1.read()) != -1 || (c = in2.read()) != -1) {
          System.out.print((char)c);
      }
  </code></pre>