Thursday, November 11, 2010

How to open notepad using java program

It is very simple to open a note pad using your java program..

And this is achieved by a class named ProcessBuilder ,
All processes are represented Process class and ProcessBuilder offers more control more over the processes.

ProcessBuilder defines three constructors.

ProcessBuilder(List<String> args)


Here args are list of arguments that specify the name of the progrm to be executed along with any reqired command line arguments.

Now lets see an example which open notepad..

class ProcessDemo{
public static void main(String[] jfb){
ProcessBuilder proc=new ProcessBuilder("notepad.exe","JBFB");
}catch(Exception hj){
System.out.println("Error not der"+hj);
To compile it in Eclipse IDE see here
I guess no need of explaining it is very simple..You can try few more editors or other applications to open with java program.


  1. This is working

  2. it very help for me
    thanks u very much