title: Runtime.getRuntime().exec(), executing Java class
body: <p>I am executing Java class from inside my application.</p>
  
  <pre><code>proc = Runtime.getRuntime().exec("java Test");
  </code></pre>
  
  <p>How can I recognize whether <code>Test</code> executed successfully or not (i.e. no exceptions)?</p>
  
  <hr>
  
  <p>Redirecting output / error:</p>
  
  <pre><code>proc = Runtime.getRuntime().exec(new String[] {
      "java",
      mclass,
      "&gt;NUL 2&gt;test.txt"
  });
  </code></pre>
  
  <p>From <code>cmd</code>:</p>
  
  <pre><code>java Main &gt;NUL 2&gt;test.txt
  </code></pre>