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. Tim Archer

    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!

Leave a Comment




  • Windows Live Writer isn’t bad Until recently, the bulk of my writing was done on a Mac using Ecto.  I was looking for a suitable publishing tool for Windows and was directed towards ...

  • Pet Peeve: Don’t email my password to me in plain text You know the drill. Signup for some random service on the internet Receive a confirmation email with your account information or Forget a password for some random service ...

  • Eclipise Memory Analyzer (MAT) I must say the Eclipse Memory Analyzer looks pretty slick. There is some pretty good material over on the developers blog. Lastly, there was a talk on it ...

  • Open-source Web-based Code Review Tool: Rietveld Guido van Rossum, of Python fame, has recently released a Django-based application that enables web-based code reviews... Rietveld. It supports any language and currently can hook into Subversion repositories. You ...

  • An implementation of the JVM in Javascript? Caught this over on JavaPosse Google Groups. Essentially, some bright fellows over in Japan have developed a bytecode->javascript compiler. There's a demo floating around that took a Tetris ...