Process: exitValue() : Process « java.lang « Java by API






Process: exitValue()

 
/*
 * Output:
 * 

notepad returned 0

 * 
 *  
 */

public class MainClass {
  public static void main(String args[]) {
  Runtime r = Runtime.getRuntime();
  Process p = null;
  String cmd[] = { "notepad", "/java/src/java/lang/Runtime.java" };
  try {
      p = r.exec(cmd);
      p.waitFor();
  } catch (Exception e) {
      System.out.println("error executing " + cmd[0]);
  }
  System.out.println(cmd[0] + " returned " + p.exitValue());
  }
}

           
         
  








Related examples in the same category

1.Process: getInputStream()
2.Process: getOutputStream()
3.Process: waitFor()