Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

why isnt my wait() and waitFor() working? please help



On the PC i have the following:

Process p = Runtime.getRuntime().exec("C:\\program Files\\QuickTime\\QuickTimePlayer.exe "
+file.getPath());
p.waitFor();

It basically creates a process of QuicktimePlayer and runs the file specified. I then have p.waitFor() used to wait for the user to close the application so i can do listener stuff for it- it worked for PC.

On Mac
String b= "open"+ tempFile.getPath();
Process p= Runtime.getRuntime().exec(b);
System.out.println("before wait");
p.waitFor(); .
System.out.println("app. terminated");

output:*
before wait
Program terminates before System.out.println("app. terminated"); but the application (quicktime) starts.

if I do this:
String b= "open"+ tempFile.getPath();
Process p= Runtime.getRuntime().exec(b);
System.out.println("before wait");

// p.waitFor(); .
System.out.println("app. terminated");

output:*
before wait
app.terminated

program terminates "normally" and I see "app.terminated".

I used Eclipse so the "red square" turns red when running it and suddenly grays out when the player appears. So to me the program terminated before the p.waitFor(); If i commented out p.waitFor() then the program goes to the System.out statement and everything goes "fine". I tried using thread.wait(), this.wait() p.wait() etc. but i get errors saying they are not owner of the thread. I am not sure why the program terminates before waitFor() and goes through if waitFor() isnt there.. please help!

 thanks


Yahoo! Mail
Use Photomail to share photos without annoying attachments.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.