×

Loading...

Jabber's toy code--001---Start an external process from within Java virtual machine

Let me say that we want to launch NotePad from with JVM. Here is the toy code:

public class NotepadLauncher{
public static void main(String args[]) throws Exception{
Runtime rt = Runtime.getRuntime();
Process p=rt.exec("notepad.exe");
p.waitFor();
}
}

Here are some questions: 1) Can we designate Notepad to open a specific file, say, abc.txt? 2) What is the effect of "p.waitFor()" ? 3) Do we need set PATH for notepad at windows machine? Is this a good example to teach people the significane of PATH in the programming? Many people have done several year's programming but they still have no sense of the environmental variable "PATH".
Sign in and Reply Report