title: How do I open an image in the default image viewer using Java on Windows?
body: <p>I have a button to view an image attached to a log entry and when the user clicks that button I want it to open the image in the user's default image viewer on a Windows machine?</p>
  
  <p>How do I know which viewer in the default image viewer?</p>
  
  <p>Right now I'm doing something like this but it doesn't work:</p>
  
  <pre><code>String filename = "\""+(String)attachmentsComboBox.getSelectedItem()+"\"";
  Runtime.getRuntime().exec("rundll32.exe C:\\WINDOWS\\System32\\shimgvw.dll,ImageView_Fullscreen "+filename);
  </code></pre>
  
  <p>And by doesn't work I mean it doesn't do anything. I tried to run the command just in the command line and nothing happened. No error, nothing.</p>