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!

Desktop.open() Problem

843810Mar 6 2008
I recently put together an application that relied heavily on the Desktop.open( ) method and several other methods from the Desktop class. However, all of a sudden the Desktop.open() does not work. I believe I read some where that this was due to the ShellExecute function or dll or something like that.

However, since my app is targetted at the Windows platform I resorted to using windows Explorer to launch the system default applications for files using a the code below
public static void openFile(File file) {
  try {
    Runtime runtime = Runtime.getRuntime();
    runtime.exec( "explorer.exe \"" + file.getAbsolutePath() + "\"" );
  } catch(IOException) {
    ioe.printStackTrace();
    JOptionPane.showMessageDialog(null, "Could Not Open File Location: " + file.getAbsolutePath());
  }
}
The code works as expected, but my problem is that I am loosing cross-platform functionality.

Can any point my to solution to this Desktop.open( ) problem, or probably add the my list platform dependent launch procedures so at least the code works on Windows,Linux and Mac.

ICE
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 3 2008
Added on Mar 6 2008
0 comments
157 views