Good example.
I just tried this small assisment. Hope I can learn more from you.
1. I did like this
public static void main(String args[]) throws Exception{
Runtime rt = Runtime.getRuntime();
Process p=rt.exec("notepad.exe c:\\users\\file\\java\\abc.txt");
p.waitFor();
}
2. the waitFor will cause the current thread to wait, if necessary, until the process represented by this Process object has terminated. So the program will pause until you finished with notepad
3. no need to set path for notepad in Windows. It's under the default Window directory.
Question: If I am running another program, say "catchme.exe", I should either add the path to exec or put the path in PATH variable, right?
I just tried this small assisment. Hope I can learn more from you.
1. I did like this
public static void main(String args[]) throws Exception{
Runtime rt = Runtime.getRuntime();
Process p=rt.exec("notepad.exe c:\\users\\file\\java\\abc.txt");
p.waitFor();
}
2. the waitFor will cause the current thread to wait, if necessary, until the process represented by this Process object has terminated. So the program will pause until you finished with notepad
3. no need to set path for notepad in Windows. It's under the default Window directory.
Question: If I am running another program, say "catchme.exe", I should either add the path to exec or put the path in PATH variable, right?