I'm wondering if you can put the main class (or the class with the init method, whatever) inside a package and still have it run in a browser? Most of the time I put my applets into the (default package) but my applet here is in a package, so can I still embed it into the webpage?
I've googled it with little results. Say I've got MyApplet.class
in a directory called app
in the jar file called MyApp.jar
.
I've tried these with no success:
<applet archive="MyApp.jar" code="MyApplet.class">
<applet archive="MyApp.jar" code="app/MyApplet.class">
<applet archive="MyApp.jar" code="/app/MyApplet.class">
<applet archive="MyApp.jar/app/" code="MyApplet.class">
<applet archive="MyApp.jar" codebase="app/" code="MyApplet.class">
Each of these gives me a ClassNotFoundException.
Thanks in advance.
The archive attribute should contain the file name of the jar, and it should be placed in the same directory as the web page.
The class file in the code attribute should contain the fully qualified class name separated by forward slashes to indicate the directory structure.
Therefore, in your list of trials attempted, trial 2 should succeed, provided that MyApp.jar is actually present along side the html page. Additionally, MyApp.jar should contain the 'app' directory in the root, which should contain the MyApplet classfile. Don't forget to have MyApplet class itself in the app package.
You could take a look at this page for reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With