java- how to stop process on button clicking
<p>I am trying to create GUI with Start and Stop Process Button. On Clicking start button a process is started and when user clicks on stop button it should stop the running process but when process started control never return back to original GUI.
    Can anybody have solution for it?
 Code Snippet is as follows:-</p>

<pre><code>private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                         
     // TODO add your handling code here:
            try {
      jTextArea1.setText("\nC:\\peach\\peach.bat --debug "+jFormattedTextField4.getText()+"\n\n");
    if(jFormattedTextField4.getText().isEmpty()){
       JOptionPane.showMessageDialog(null, "Browse The Peach  File First");
    }
    else
    {

            String line=new String(jFormattedTextField4.getText());
    OutputStream stdin = null;
    InputStream stderr = null;
    InputStream stdout = null;

    // launch EXE and grab stdin/stdout and stderr
    //process = Runtime.getRuntime ().exec("C:\\peach\\peach.bat --debug "+line);
    stdin = process.getOutputStream ();
    stderr = process.getErrorStream ();
    stdout = process.getInputStream ();
    stdin.close();

    // clean up if any output in stdout
    BufferedReader brCleanUp = new BufferedReader (new InputStreamReader (stdout));
        while ((line = brCleanUp.readLine ()) != null) {
            System.out.println ("[Stdout] " + line);
                            jTextArea1.append("[Stdout]--&gt;"+line+"\n");
        }
    brCleanUp.close();

            // clean up if any output in stderr
    brCleanUp = new BufferedReader (new InputStreamReader (stderr));
        while ((line = brCleanUp.readLine ()) != null) {
        System.out.println ("[Stderr]--&gt;" + line);
                    jTextArea1.append("[Stderr]"+line+"\n");
        }
    brCleanUp.close();

    }

  }
   catch (Exception err) {
  err.printStackTrace();
}
</code></pre>

<p>}                                        </p>

<p>private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {<br>
        // TODO add your handling code here:</p>

<pre><code>    process.destroy();    
</code></pre>

<p>}                                        </p>
