src/main/java/org/funz/calculator/plugin/DefaultCodeLauncher.java
public void stopRunning() {
        if (tunnel != null) {
            tunnel.stop();
            tunnel = null;
        }        
        if (_progressSender != null) {
            _progressSender.askToStop();
        }

        if (_process != null) {
            _process.stop();
        }

        File killbat = new File(_dir, "STOP.bat");
        if (killbat.isFile()) {
            try {
                Runtime.getRuntime().exec("cmd.exe " + killbat.getName());
            } catch (Exception e) {
                System.err.println("could not launch STOP.bat:\n" + e);
            }
            killbat.delete();
        }

        File killsh = new File(_dir, "STOP.sh");
        if (killsh.isFile()) {
            try {
                Runtime.getRuntime().exec("/bin/sh " + killsh.getName());
            } catch (Exception e) {
                System.err.println("could not launch STOP.sh:\n" + e);
            }
            killsh.delete();
        }

        File pid = new File(_dir, "PID");
        if (pid.isFile()) {
            String[] pids = getASCIIFileLines(pid);
            for (int i = 0; i < pids.length; i++) {
                System.err.println("Killing PID " + pids[i]);
                int p = 0;
                try {
                    p = Integer.parseInt(pids[i]);
                } catch (NumberFormatException nfe) {
                    continue;
                }
                if (System.getProperty("os.name").toLowerCase().indexOf("windows") > 0) {
                    exec("taskkill /PID " + p + " /T /F");
                } else {
                    exec("kill -2 " + p);
                    exec("kill -15 " + p);
                    exec("kill -9 " + p);
                }

            }
            pid.delete();
        }
        if (shutdown != null && !shutdown.isAlive()) {
            Runtime.getRuntime().removeShutdownHook(shutdown);
        }
    }
/**
     * Method to cancel an execution, for instance when the user press the
     * "stop" button on the GUI. This extended version of the method tries to
     * stop the running calculation process using these steps:
     * <br/>1. try to kill with Process.destroy method, and closes the
     * out/err/in streams.
     * <br/>2. try to find a STOP.bat file to launch using cmd.exe
     * <br/>3. try to find a STOP.sh file to launch using cmd.exe
     * <br/>4. try to find a PID file, and call "taskkill /PID pid /T /F" (or
     * kill -2, -15, -9 in Unix) for each integer in this file.
     */
Method to cancel an execution, for instance when the user press the
"stop" button on the GUI. This extended version of the method tries to
stop the running calculation process using these steps:
1. try to kill with Process.destroy method, and closes the
out/err/in streams.
2. try to find a STOP.bat file to launch using cmd.exe
3. try to find a STOP.sh file to launch using cmd.exe
4. try to find a PID file, and call "taskkill /PID pid /T /F" (or
kill -2, -15, -9 in Unix) for each integer in this file.
Method to cancel an execution for instance when the user press the " stop " button on the GUI . This extended version of the method tries to stop the running calculation process using these steps : 1 . try to kill with Process . destroy method and closes the out / err / in streams . 2 . try to find a STOP . bat file to launch using cmd . exe 3 . try to find a STOP . sh file to launch using cmd . exe 4 . try to find a PID file and call " taskkill / PID pid / T / F " ( or kill - 2 - 15 - 9 in Unix ) for each integer in this file .
public void stopRunning() {
        if (tunnel != null) {
            tunnel.stop();
            tunnel = null;
        }        
        if (_progressSender != null) {
            _progressSender.askToStop();
        }
        if (_process != null) {
            _process.stop();
        }
        File killbat = new File(_dir, "STOP.bat");
        if (killbat.isFile()) {
            try {
                Runtime.getRuntime().exec("cmd.exe " + killbat.getName());
            } catch (Exception e) {
                System.err.println("could not launch STOP.bat:\n" + e);
            }
            killbat.delete();
        }
        File killsh = new File(_dir, "STOP.sh");
        if (killsh.isFile()) {
            try {
                Runtime.getRuntime().exec("/bin/sh " + killsh.getName());
            } catch (Exception e) {
                System.err.println("could not launch STOP.sh:\n" + e);
            }
            killsh.delete();
        }
        File pid = new File(_dir, "PID");
        if (pid.isFile()) {
            String[] pids = getASCIIFileLines(pid);
            for (int i = 0; i < pids.length; i++) {
                System.err.println("Killing PID " + pids[i]);
                int p = 0;
                try {
                    p = Integer.parseInt(pids[i]);
                } catch (NumberFormatException nfe) {
                    continue;
                }
                if (System.getProperty("os.name").toLowerCase().indexOf("windows") > 0) {
                    exec("taskkill /PID " + p + " /T /F");
                } else {
                    exec("kill -2 " + p);
                    exec("kill -15 " + p);
                    exec("kill -9 " + p);
                }
            }
            pid.delete();
        }
        if (shutdown != null && !shutdown.isAlive()) {
            Runtime.getRuntime().removeShutdownHook(shutdown);
        }
    }
public void stopRunning ( ) { if ( tunnel != null ) { tunnel . stop ( ) ; tunnel = null ; } if ( _progressSender != null ) { _progressSender . askToStop ( ) ; } if ( _process != null ) { _process . stop ( ) ; } File killbat = new File ( _dir , "STOP.bat" ) ; if ( killbat . isFile ( ) ) { try { Runtime . getRuntime ( ) . exec ( "cmd.exe " + killbat . getName ( ) ) ; } catch ( Exception e ) { System . err . println ( "could not launch STOP.bat:\n" + e ) ; } killbat . delete ( ) ; } File killsh = new File ( _dir , "STOP.sh" ) ; if ( killsh . isFile ( ) ) { try { Runtime . getRuntime ( ) . exec ( "/bin/sh " + killsh . getName ( ) ) ; } catch ( Exception e ) { System . err . println ( "could not launch STOP.sh:\n" + e ) ; } killsh . delete ( ) ; } File pid = new File ( _dir , "PID" ) ; if ( pid . isFile ( ) ) { String [ ] pids = getASCIIFileLines ( pid ) ; for ( int i = 0 ; i < pids . length ; i ++ ) { System . err . println ( "Killing PID " + pids [ i ] ) ; int p = 0 ; try { p = Integer . parseInt ( pids [ i ] ) ; } catch ( NumberFormatException nfe ) { continue ; } if ( System . getProperty ( "os.name" ) . toLowerCase ( ) . indexOf ( "windows" ) > 0 ) { exec ( "taskkill /PID " + p + " /T /F" ) ; } else { exec ( "kill -2 " + p ) ; exec ( "kill -15 " + p ) ; exec ( "kill -9 " + p ) ; } } pid . delete ( ) ; } if ( shutdown != null && ! shutdown . isAlive ( ) ) { Runtime . getRuntime ( ) . removeShutdownHook ( shutdown ) ; } }
Method to cancel an execution, for instance when the user press the
 "stop" button on the GUI.
Method to cancel an execution for instance when the user press the " stop " button on the GUI .