Mailing Lists: Apple Mailing Lists

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

Re: Launching Mac applications and passing parameters




On Jan 7, 2006, at 6:56 AM, Thomas Singer wrote:

Hi,

Most likely this is a dumb question, but I searched google and could not find an answer: how do I run Mac applications and pass parameters (from Java)? I've tried something like

 Runtime.getRuntime().exec(new String[] {
   "/Applications/Preview.app/Contents/MacOS/Preview",
   "/Users/tom/test.png"
 });

But that just opens the Preview application without opening the graphic. Is there a general way like "start foo.png" on Windows?

Applications (especially bundled based applications) on Mac OS X don't usually get file open requests as a command line argument. Instead they get open AppleEvents. This allows, for example, an already running instance of Preview.app to open a document that a use double clicked.


Consider using the "open" command to do what you want since it generates the correct launch services operations and sends the correct apple events. You could also use the services of com.apple.eio.FileManager [1].

-Shawn

[1] <http://developer.apple.com/documentation/Java/Reference/1.4.2/ appledoc/api/com/apple/eio/FileManager.html>
_______________________________________________
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
References: 
 >Launching Mac applications and passing parameters (From: Thomas Singer <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.