title: error opening files with Desktop in java (windows 7)
body: <p>I created a program that generates an excel spreadsheet (.xls), then asks if the user wants to open it immediately (if so, it uses java.awt.Desktops open() command to do so). This is working fine in windows xp, but when I tried with windows 7 it didn't work. Below is a sample of my code...</p>
  
  <pre><code>Desktop myDesk = null;
  
  //if printed to file successfully and java.awt.Desktop is supported
  if (printed &amp;&amp; Desktop.isDesktopSupported())
  {   
      myDesk = Desktop.getDesktop();
  
      if (myDesk.isSupported(Desktop.Action.OPEN))
      {
           //ask to open file
          int openFile = JOptionPane.showConfirmDialog(null, "File successfully 
                            created.\nWould you like the excel file to open?", 
                            "open file?", JOptionPane.YES_NO_OPTION);
  
          //try to open file
          if (openFile == JOptionPane.YES_OPTION)
          {
              try { myDesk.open(myFile); }
              catch (IOException e){ JOptionPane.showMessageDialog(null, "Problem 
                                      opening file automatically, please open it
                                      yourself.", "Error", JOptionPane.ERROR_MESSAGE); }
          }
      }
  }
  </code></pre>
  
  <p>On windows 7 this successfully prints to file, it shows the openFile dialogue, then shows the error dialogue. This shouldn't happen, as in order to get to the openFile dialogue Desktop and Desktop.open() should both be supported. It could possibly have something to do with trying to open a ".xls" file instead of ".xlsx" file, but excel should still be set as default for either file type...</p>
  
  <p>So any ideas about why this is happening? And either how to fix it or if there's an alternate way to open a file that works better universally?</p>