Menu
Topics Index
...
`

RuntimeDemo - Java Example Program


RuntimeDemo
class RuntimeDemo
{
    public static void main(String args[])
        {
            Runtime Objrun=Runtime.getRuntime();//LINE A
            Process Objprocess=null;// LINE B
            try
            {
                Objprocess=Objrun.exec("notepad.exe");//LINE C
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }
}
OUTPUT

DESCRIPTION

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 exec().

THINGS TO TRY
  • If we run the above program in our desktop or in our laptops we can get notepad window.

© meritcampus 2019

All Rights Reserved.

Open In App