0 Replies Latest reply: Feb 7, 2013 11:56 PM by 969106 RSS

    OS X and Desktop.open()

    969106
      I use the following code to open an image with the default image viewer on Mac OS X.

      Runtime.getRuntime().exec(new String[]{"/usr/bin/open", data.directory + File.separatorChar + data.name});

      It works fine in development but as soon as I run it in a signed web start application, it only works if "Preview" (the default image app) is already open. No exceptions are thrown when it doesn't work.

      Interestingly, I have a "Show In Finder" option that uses a variation of the same command:

      Runtime.getRuntime().exec(new String[]{"/usr/bin/open", "-R", data.directory + File.separatorChar + data.name});

      It works every time regardless of whether I'm running in web start or not.

      I also tried using Desktop.open() and it behaves exactly the same way. This is on Mac OS X mountain lion with JDK 1.7u13.