title: Unable to deploy any applet built by NetBeans
body: <p>I'm new to Java. I'm unable to deploy any applet on a html page and constantly getting InvocationTargetException. To illustrate this, here is an example:</p>
  
  <p>My applet has only one class that has a main. All the code are generated by NetBeans and the GUI contains only one button:</p>
  
  <pre><code>package javaapplication;
  
  public class NewJFrame extends javax.swing.JFrame {
      public NewJFrame() {
          initComponents();
      }
  
      @SuppressWarnings("unchecked")
  
  
     // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt;                          
      private void initComponents() {
  
          jButton1 = new javax.swing.JButton();
  
          setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
  
          jButton1.setText("jButton1");
  
          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
          getContentPane().setLayout(layout);
          layout.setHorizontalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addComponent(jButton1)
                  .addContainerGap(317, Short.MAX_VALUE))
          );
          layout.setVerticalGroup(
              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
              .addGroup(layout.createSequentialGroup()
                  .addContainerGap()
                  .addComponent(jButton1)
                  .addContainerGap(266, Short.MAX_VALUE))
          );
  
          pack();
      }
      public static void main(String args[]) {
      /* Set the Nimbus look and feel */
      //&lt;editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "&gt;
      /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
       * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
       */
      try {
          for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
              if ("Nimbus".equals(info.getName())) {
                  javax.swing.UIManager.setLookAndFeel(info.getClassName());
                  break;
              }
          }
      } catch (ClassNotFoundException ex) {
          java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
      } catch (InstantiationException ex) {
          java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
      } catch (IllegalAccessException ex) {
          java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
      } catch (javax.swing.UnsupportedLookAndFeelException ex) {
          java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
      }
      //&lt;/editor-fold&gt;
  
      /* Create and display the form */
      java.awt.EventQueue.invokeLater(new Runnable() {
          public void run() {
              new NewJFrame().setVisible(true);
          }
      });
      }
      // Variables declaration - do not modify                     
      private javax.swing.JButton jButton1;
      // End of variables declaration      
  }
  </code></pre>
  
  <p>It compiles and runs smoothely, within NetBeans. Now I clean and build the .jar file. Here's the MANIFEST.MF, which looks fine to me:</p>
  
  <pre><code>Manifest-Version: 1.0
  Ant-Version: Apache Ant 1.8.4
  Created-By: 1.7.0_10-b18 (Oracle Corporation)
  Class-Path: 
  X-COMMENT: Main-Class will be added automatically by build
  Main-Class: javaapplication.NewJFrame
  </code></pre>
  
  <p>Here is my index.html:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;applet archive="JavaApplication.jar" width="300" height="300" code="javaapplication.NewJFrame"/&gt;
  
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>I've put them in the same directory and set permission properly as well. Now when I try to open my index.html which is placed on server, it gives InvocationTargetException, on both newest versions of Firefox and Chrome.</p>
  
  <p>I'm tried many different things like creating a another class that has a main, or using Jnlp but no avail. Any help is greatly appreciated.</p>