It worked just as you said it would. Thank you for the insight! Jim
On Jan 22, 12:50 am, "A.S.El-Dalatony" <[email protected]> wrote: > Hi Jim, > > the purpose of waitFor() method as you can see form java > documentationhttp://java.sun.com/javase/6/docs/api/java/lang/Process.html#waitFor() > > is to block the current process untill the program you opened terminates > > so if you try this block of code > try { > proc = rt.exec("regedit"); > proc.waitFor(); > proc = rt.exec("calc"); > } catch (Exception e) { > System.out.println("regedit is an unknown command."); > } > > the calculator program won't start untill you close the "regedit" > but if you removed the waitFor() method the two programs will start together > > Hope I Helped > > On 1/22/09, Jim <[email protected]> wrote: > > > > > > > Hi, > > > I have a question about one of the examples in the lesson "Tour of > > java.lang.* and java.util.* classes". The example is about the > > Process and Runtime classes. Here is the example program: > > > 1 class RuntimeDemo { > > 2 public static void main(String args[]) { > > 3 Runtime rt = Runtime.getRuntime(); > > 4 Process proc; > > 5 try { > > 6 proc = rt.exec("regedit"); > > 7 proc.waitFor(); //try removing this line > > 8 } catch (Exception e) { > > 9 System.out.println("regedit is an unknown > > 10 command."); > > 11 } > > 12 } > > 13 } > > > When I ran the program, the Registry Editor appeared. i tried running > > the program with and without the proc.waitFor() line, and did not > > notice any difference between the programs. In both cases, the > > Registry Editor appeared, and when I closed the editor, the program > > stopped. > > > What should the different behaviors be for the two programs? I use > > NetBeans 6.5. Thank you! > > > Jim Tarsi- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
