I have tried

hailstorm (鹏飞北溟)
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");

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?

2001-6-20 -04:00

回到话题: Jabber's toy code--001---Start an external process from within Java virtual machine

回到论坛: HOME枫下论坛枫下论坛主坛工作学习IT技术讨论