title: How to fix/workaround java.lang.reflect.InvocationTargetException
body: <p>I've got a question about a particularly annoying error that I haven't been able to figure out, much less overcome.  Any time I try to run a Java applet (Applet or JApplet) on my website, I get this error as a pop-up:</p>
  
  <pre><code> java.lang.reflect.InvocationTargetException
  </code></pre>
  
  <p>No stack trace, no line number, just the error message.  So I've Googled around looking for anyone else's workarounds (or ideally actual fixes) but haven't been able to find much.  I've tried several variations of my code (sometimes with a JAR file, sometimes not, sometimes a single class, sometimes not, sometimes in a package using a matching directory structure, sometimes no package, etc.) but can't seem to get past this nasty little son-of-a-bug. :)</p>
  
  <p>For a specific example, here's my most recent attempt; first the Java code:</p>
  
  <pre><code>package cmtoolbox;
  
  public class CMToolbox {
      public static void main(String[] args) {
          MainApplet a = new MainApplet();
      }
  }
  </code></pre>
  
  <p>The class it sets up:</p>
  
  <pre><code>package cmtoolbox;
  
  import javax.swing.JApplet;
  import javax.swing.JButton;
  
  public class MainApplet extends JApplet {
      public MainApplet() {
          JApplet main = new JApplet();
          main.setSize(800,600);
          JButton test1 = new JButton();
          test1.setText("Test");
          main.add(test1);
      }
  }
  </code></pre>
  
  <p>My HTML code:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt; Experimenting with Java applets &lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;p&gt;&lt;applet code="CMToolbox.class" width="800" width="600"&gt;
      I wish. :)
    &lt;/applet&gt;&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I suppose that maybe because the web itself can have so many variables (operating systems, browser types, etc.) there is something internal/system-level causing this... but I do have the JRE and JDK installed on my computer so I don't really get why... Anyway, I'm sure I'm not the first guy to hit this roadblock, but it's got me stumped so I'd appreciate any info that may be available on the subject.  Also if you know of any good Java web tutorials for absolute noobs that would be great as well. :)</p>