JDIC and OS X : Revisited

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.