Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

opening a file via Runtime.exec() on Mac OS X

843798Jul 25 2007 — edited Aug 14 2007
I'm having a hard time opening a file on Mac OS X.

The following code works only if the filepath/filename doesn't contain a space:
String filepath;
Runtime rt = Runtime.getRuntime();
rt.exec( "open " + filepath);
From a terminal, I can surround the filepath with either apostrophes or quotes and OS X will open the file no problem, even if it has spaces.

If I call:
filepath = "\"" + filepath + "\"";
rt.exec( "open " + filepath);
...then nothing happens. No error, no popup, no exception thrown...nothing. Same thing if I use apostrophes vice quotes.

Any ideas? I'm using JDK 5.0 as 6.0 is not yet supported by Apple.

Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 11 2007
Added on Jul 25 2007
2 comments
532 views