JDIC and OS X : Revisited

February 7, 2006 | In: Java, Open Source Software

I blogged a few days ago about an exception that was cropping up when doing a Desktop.open() on OS X.

Tonight I hacked out a simple solution.

Instead of

Desktop.open(file);

I do:

if (OSUtils.isMacintosh())
{
Runtime.getRuntime().exec(“open”, file);
}
else
{
Desktop.open(file)
}

OSUtils.isMacintosh() just does a check against ‘os.name’ to see if it matches the signature of a macintosh.

Pretty simple. I haven’t actually tried it out in the application yet, but a simple test had it launching the native text editor so it appears to work as expected.



1 Response to JDIC and OS X : Revisited

Avatar

Tim Archer

April 7th, 2007 at 2:04 pm

I’ll have to try your problem out on a mac.
I use JDIC to open files for my apps that need to run across platforms and did a little write up on it at:
http://timarcher.com/?q=node/17

I have never encountered the error such as you’re describing. I’m going to have to try to grab a mac at work and test it our. Thanks for the heads up, hopefully you’re finding will save me some headaches later on down the road. I’m requiring JDK 1.5 for my app, so I’m really hoping JDIC properly opens files under that JVM!

Comment Form

RSSTwitter Feed

del.icio.us