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

jabber (jabber)
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".
(#107319@0)
2001-6-20 -05:00

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

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

URL:   
http://www.rolia.net/zh/post.php?f=0&p=107319