Runtime class encapsulates the run-time environment.The current runtime can be obtained from the
getRuntime method.Once we obtain a reference to the current Runtime object,we can call several methods that control the state and behaviour of the JVM.Basically this class is used for memory management and executing additional processes.
The Runtime class has various methods ranging from executing processes to exiting their instances.
The declaration for Runtime class is shown below:
public class Runtime extends Object
Following table shows some of the commonly used methods of Runtime class
public static void main(String args)
Runtime Objrun=Runtime.getRuntime();//LINE A
Process Objprocess=null;// LINE B
At LINE A we canget correct runtime by using
getRuntime().At LINE B we can intialised process as
null.At LINE C we executed
notepad.exe command by using
THINGS TO TRY
- If we run the above program in our desktop or in our laptops we can get