2

I'm trying to embed a Java applet that I just made into an HTML 5 compliant page. I'm using the following tag to embed the .jar file:

<object type="application/x-java-applet" height="300" width="550">
      <param name="code" value="MainClassName" />
      <param name="archive" value="MyJarFileName.jar" />
      Applet failed to run.  No Java plug-in was found.
</object>

The java applet will try to run but stop with:

java.lang.reflect.InvocationTargetException

I'm having trouble finding what is the cause of this error. My .jar file will run fine on its own. The main class extends JApplet, which contains a frame, which contains a JPanel.

What is causing this error?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
nwnoga
  • 577
  • 3
  • 12
  • 22
  • this could help: http://stackoverflow.com/questions/6955790/applet-java-lang-reflect-invocationtargetexception – kennypu Dec 29 '12 at 03:16
  • 1
    1) `InvocationTargetException` is often caused by the applet not being declared `public`. 2) Use `deployJava.js` to write the element. 3) If the applet is available at a public URL where we can visit it, supply the URL. 4) *"extends JApplet, which contains a frame, which contains a JPanel."* What exactly DYM by 'frame'? An applet should not typically be launching a `JFrame` or `Frame`. – Andrew Thompson Dec 29 '12 at 03:33
  • That was exactly it, my main constructor was private. Now I don't get an error but it wont load. The example that i saw in https://eyeasme.com/Shayne/HTML5_APPLETS/Sample.java does the same thing I did: create a Frame from the Main class which extends JApplet – nwnoga Dec 29 '12 at 04:20
  • I just threw it up here:https://dl.dropbox.com/u/38434655/index.html – nwnoga Dec 29 '12 at 04:31
  • @nwnoga: Please edit your question to cite your sources and include an [sscce](http://sscce.org/) that exhibits the current problem. It's unlikely that anyone will endure dropbox see your code. Also consider [tag:javawebstart] and a [hybrid](http://stackoverflow.com/a/12449949/230513) applet/application. – trashgod Dec 29 '12 at 11:16
  • Try viewing the Java console to see if there are any errors. Don't ask additional questions if the main question has been sufficiently answered... – Maarten Bodewes Jun 14 '13 at 00:57

0 Answers0