title: How to stop a process start by ProcessBuilder in java
body: <p>I start processes with ProcessBuilder in Java.  Multiple process may be started.  How do I stop a Process?</p>
  <pre><code>public void terminalExecute(String builder) throws InterruptedException
  {
      System.out.println(builder);
      String[] splits = builder.split(&quot; &quot;);
      System.out.println(splits.length);
  
      ProcessBuilder pb = new ProcessBuilder(splits[0],splits[1],splits[2],splits[3],splits[4],splits[5],splits[6],splits[7]);
      Process p = null ;
      pb.redirectErrorStream(true); 
      try {
          p = pb.start();
  
          BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
          String s = &quot;&quot;;
          while((s = in.readLine()) != null){
              System.out.println(s);
          }
          int status = p.waitFor();
          System.out.println(&quot;Exited with status: &quot; + status);
      } catch (IOException e) {
          e.printStackTrace();
      }
  
     
  }
  </code></pre>
  <p>In another class I called this function like :</p>
  <pre><code> String cmd =&quot;java -Xmx3024m -XX:MaxPermSize=512m -Xms1024m -cp &quot;+ ConfReader.getAFFJarPath()+&quot; core.StrWorkflow &quot;+new BigInteger(serviceRequest.getBytes());
   ProcessExecutor procExec = new ProcessExecutor();
   procExec.terminalExecute(cmd);
  </code></pre>
  <p>How I get the process id in this class ?</p>