Java Process.exitValue()

Syntax

Process.exitValue() has the following syntax.

public abstract int exitValue()

Example

In the following code shows how to use Process.exitValue() method.


//from w  ww.  ja  v  a2s.c o  m
public class Main {

   public static void main(String[] args) {
      try {
         // create a new process
         Process p = Runtime.getRuntime().exec("notepad.exe");

         p.destroy();

         System.out.println(p.exitValue());

      } catch (Exception ex) {
         ex.printStackTrace();
      }

   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable