Shou ryuujo wrote:
>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");
>...
>I am not sure why the program terminates before waitFor() and goes through
>if waitFor() isnt there.. please help!
When you use the "open" command, you are executing the command 'open',
which then launches the appropriate app for the path (i.e. QT Player). The
Process is ONLY the 'open' command itself. It does NOT represent the
eventual application that opens the file: QT Player.
Try the equivalent in Terminal.app. When you type a command line:
open /Users/yourname/yourfile.mov
and hit Return, the 'open' command returns very quickly, because all 'open'
does is launch another process and then terminate. And so it is with your
Java Process.
The reason it works differently on Windows is because you're doing it
differently on Windows. You aren't using an indirect intermediate app or
command; you're exec()'ing QT Player directly. The rough equivalent to
'open' on Windows is the 'start' command, though it's not identical. Type
'help start' in a command prompt window.
If you want to do "listener stuff" for QT Player or wait for it to quit,
you should look into scripting it. The simplest way I know of to do that
with Java is to exec() the 'osascript' command (again, an indirect
intermediate command) and pass it immediate scripts using its -e option.
Read 'man osascript', and then refer to any AppleScript reference for
scripting syntax.
By the way, your code as given will fail if the File's pathname contains a
space. You should always use the exec(String[]) forms, never the
single-String forms. For the 'open' command, the command-name and each
single arg should be a String in the String[]. Search the archives for
"exec" for more examples.
-- GG
_______________________________________________
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