title: How do i open a PDF file in Netbeans?
body: <p>I want my application to open a pdf file when I click a dedicated button. How would i approach this? Also if I run the application from netbeans it shows the pdf but when compiled nothing comes up? </p>
  
  <p>My code</p>
  
  <pre><code>    private void showHelpMenuItemActionPerformed(java.awt.event.ActionEvent evt) {                                                 
          File f = new File("ana.pdf");
      try {
        Desktop.getDesktop().open(f);
    } catch (Exception ex) {
      System.out.println(ex);}
  </code></pre>