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()



    Guys,
Yes I just verified it. All I did was change from String to String[] and it worked. I guess I could look at the exec() source to see how the too are different.
 
Thanks,
Navin


From: java-dev-bounces+njha=email@hidden [mailto:java-dev-bounces+njha=email@hidden] On Behalf Of Anthony Magee
Sent: Tuesday, August 22, 2006 1:26 PM
To: Java-Dev Mailing List
Subject: 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




The information contained in this communication is intended for the use of the designated recipients named above.
If the reader of this communication is not the intended recipient, you are hereby notified that you have received this communication in error, and that any review, dissemination, distribution or copying of this communication is strictly prohibited.
If you have received this communication in error, please notify The Associated Press immediately by telephone at +1-212-621-1898 and delete this email. Thank you.

 _______________________________________________
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: 
 >Re: Using Runtime.getRuntime().exec() (From: Anthony Magee <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.