Runtime Exec Example
In this example we are going to execute an application using java program.
This example uses the Process class that
is contained in the lang package and extends Object
class. The method Runtime.exec() creates a native process and returns an instance of a subclass of
the Process class.
This instance is then used to control the process and to obtain the information about
the process. The Process class provides methods for performing input ,output , wait, checking the exit status
, and destroying (killing) the process.
The class Runtime contained in java.lang package and extends the Object class. Every Java application has a single instance of class Runtime. The current runtime can be obtained by using the getRuntime() method. Any application cannot create its own instance of runtime class.
The method used:
The output of the program is given below: