title: How to release process resource in java
body: <p>How to release process resource??</p>
  <pre><code>import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.OutputStream;
  import java.util.StringTokenizer;
  
  public class RuntimeSample{
      public RuntimeSample() {
      }
      private void execCmd1() throws IOException {
          InputStream in = null;
          Process process = null;
          String[] cmd = { &quot;java&quot;, &quot;-version&quot; };
          try {
              process = Runtime.getRuntime().exec(cmd);
              in = process.getInputStream();
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
              if (in != null) {
                  in.close();
              }
          }
      } 
      private void execCmd2() throws IOException {
          Process process = null;
          String[] cmd = { &quot;java&quot;, &quot;-version&quot; };
          try {
              process = Runtime.getRuntime().exec(cmd);
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
          }
      }
  }
  </code></pre>
  <p>why it is throwing process.getError stream is not closed,I tried to close process resource by using following</p>
  <pre><code>if (process != null) {
      process.getInputStream().close();
      process.getOutputStream().close();
      process.getErrorStream().close();
  </code></pre>
  <p>even it is showing process.getError stream is not closed.may i know the reason y it is showing that stream is not closed and how to close the process resource.Thanks in advance</p>