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: Using Runtime.getRuntime().exec()



Jeremy is correct here. The preferred way to use Runtime.exec() is with a String[]. Search the archives for this, it is well discussed.

String[] openPS = {"open", "-a", "Applications/Adobe Photoshop CS2/Adobe Photoshop CS2.app/Users/administrator/myapp/tmp/{555}_01.jpg"};
Runtime.getRuntime().exec(openPS);

On Aug 22, 2006, at 11:42 AM, Jeremy Wood wrote:

Exactly what does your code look like?

When you call Runtime.exec() you can pass just 1 string, or you can pass an array of strings.  I think the key might be to use an array of strings...  I have two working snippets that don't *quite* do what you want (because that would be too easy)... but if you combine them it should work:

Snippet 1:
String[] cmd = {"open",file.getAbsolutePath()};
Runtime.getRuntime().exec(cmd);

Snippet 2:
String[] cmdline = new String[] { "open", "-a", getAplicationPath()};

I'm unclear whether you've tried using arrays of strings or not, though... let me know if this helps.  If it doesn't, what does your code look like so we can test?

 - Jeremy

On Aug 22, 2006, at 9:26 AM, Jha, Navin wrote:

All,

I am running into a problem launching Photoshop from my application. I
use the following String to launch Photoshop along with an image using
exec().

Open -a "Applications/Adobe Photoshop CS2/Adobe Photoshop CS2.app"
"/Users/administrator/myapp/tmp/{555}_01.jpg"


If I use the same string on command line the Photoshop does launch with
the image. Interesting part is if I create a shortcut to Photoshop
application that does work.


Regards,
Navin

Anthony Magee
macawm_at_gmail.com
-----
“All that we are is the result of what we have thought.”
Buddha


 _______________________________________________
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: 
 >Using Runtime.getRuntime().exec() (From: "Jha, Navin" <email@hidden>)
 >Re: Using Runtime.getRuntime().exec() (From: Jeremy Wood <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.