Example usage for java.lang Process destroy

List of usage examples for java.lang Process destroy

Introduction

In this page you can find the example usage for java.lang Process destroy.

Prototype

public abstract void destroy();

Source Link

Document

Kills the process.

Usage

From source file:Main.java

public static void startView(String viewTag) {
    try {//from  ww  w .  j  a  v  a  2  s.  co m
        Process p1 = Runtime.getRuntime().exec("cleartool startview " + viewTag);
        p1.waitFor();
        p1.destroy();
    } catch (Exception e) {
        throw new RuntimeException("cleartool startview error!", e);
    }
}

From source file:Main.java

public static void rmView(String viewTag) {
    try {/*  w ww  .j ava 2 s .com*/
        Process pr = Runtime.getRuntime().exec("cleartool rmview -tag ".concat(viewTag));
        pr.waitFor();
        pr.destroy();
    } catch (Exception e) {
        throw new RuntimeException("cleartool rmview error!", e);
    }
}

From source file:Main.java

public static void setConfigSpec(String viewTag, String configSpecFilePath) {
    try {//from  w  w  w. j  av  a2s.c  om
        Process pr = Runtime.getRuntime().exec("cleartool setcs -tag " + viewTag + " " + configSpecFilePath);
        pr.waitFor();
        pr.destroy();
    } catch (Exception e) {
        throw new RuntimeException("cleartool setcs error!", e);
    }

}

From source file:com.qwazr.utils.process.ProcessUtils.java

public static Integer run(String commandLine) throws InterruptedException, IOException {
    Process process = Runtime.getRuntime().exec(commandLine);
    try {/*from   ww  w . ja v  a 2s .  co m*/
        return process.waitFor();
    } finally {
        process.destroy();
        if (process.isAlive())
            process.destroyForcibly();
    }
}

From source file:org.sonar.process.ProcessUtils.java

/**
 * Send kill signal to stop process. Shutdown hooks are executed. It's the equivalent of SIGTERM on Linux.
 * Correctly tested on Java 6 and 7 on both Mac/MSWindows
 * @return true if the signal is sent, false if process is already down
 *//*  ww  w.  j av  a2  s  .  c o  m*/
public static boolean sendKillSignal(@Nullable Process process) {
    boolean sentSignal = false;
    if (isAlive(process)) {
        try {
            process.destroy();
            sentSignal = true;
        } catch (Exception e) {
            LoggerFactory.getLogger(ProcessUtils.class).error("Fail to kill " + process, e);
        }
    }
    return sentSignal;
}

From source file:Main.java

public static String dumpFile(String filename) {
    String line = "";
    try {/*from  w  w w.  jav  a  2 s. co  m*/
        Process ifc = Runtime.getRuntime().exec("cat " + filename);
        BufferedReader bis = new BufferedReader(new InputStreamReader(ifc.getInputStream()));
        line = bis.readLine();
        ifc.destroy();

    } catch (java.io.IOException e) {
        return new String("");
    }

    return line;
}

From source file:Main.java

public static String getSystemProp(String key) {
    String line = "";
    try {/*from  ww w .j  a v a  2 s  .  c o m*/
        Process ifc = Runtime.getRuntime().exec("getprop " + key);
        BufferedReader bis = new BufferedReader(new InputStreamReader(ifc.getInputStream()));
        line = bis.readLine();
        ifc.destroy();

    } catch (java.io.IOException e) {
        return new String(LOGTAG);
    }

    return line;
}

From source file:Main.java

public static void mkView(String viewTag) {
    try {//from w  ww  . j  a v  a 2 s. com
        Process pr = Runtime.getRuntime().exec("cleartool mkview -tag " + viewTag + " \\\\"
                + InetAddress.getLocalHost().getHostName() + "\\viewstore\\" + viewTag + ".vws");
        pr.waitFor();
        pr.destroy();
    } catch (Exception e) {
        throw new RuntimeException("cleartool mkview error!", e);
    }
}

From source file:Main.java

public static String dumpFile_prev(String filename) {
    String line_prev = "";
    try {/*from   w ww . j  a  v  a 2s .c o m*/
        Process ifc_prev = Runtime.getRuntime().exec("cat " + filename);
        BufferedReader bis_prev = new BufferedReader(new InputStreamReader(ifc_prev.getInputStream()));
        line_prev = bis_prev.readLine();
        ifc_prev.destroy();

    } catch (java.io.IOException e) {
        return new String("");
    }

    return line_prev;
}

From source file:Main.java

public static String dumpFile_prev2(String filename) {
    String line_prev2 = "";
    try {/*from   ww w .j  a  v  a 2  s  . c o  m*/
        Process ifc_prev2 = Runtime.getRuntime().exec("cat " + filename);
        BufferedReader bis_prev2 = new BufferedReader(new InputStreamReader(ifc_prev2.getInputStream()));
        line_prev2 = bis_prev2.readLine();
        ifc_prev2.destroy();

    } catch (java.io.IOException e) {
        return new String("");
    }

    return line_prev2;
}