Starting Java applet directly from jar file
- by Thomas
The goal is to have an applet run from a jar file.
The problem is that the applet only seems to want to run from an exploded jar file.
Samples on the Internet suggest this applet tag:
<applet code="com.blabla.MainApplet"
archive="applet.jar"
width="600" height="600">
This will not even try to look in the jar file and fails with:
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/helloWord/com/blabbla/MainApplet.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Setting the codebase instead of the archive attribute to the jar file. Looks a bit better. However, the JVM does not realize that it has to open the jar file:
<applet code="com.blabla.MainApplet"
codebase="applet.jar"
width="600" height="600">
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8080/helloWord/applet.jar/com/blabbla/MainApplet.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
How does the applet tag have to be formulated to start an applet class from inside of a jar file?