Hello I have test.html page with this in it <APPLET codebase="." code="client.Applet.class" archive="applets.jar" width=350 height=200></APPLET> at the same level I have applets.jar with client.Applet.class
all this is in the root directory of a webapplication(at the same level of the WEB-INF). When I access it with http://localhost/context1/test.html it fails with the typical ClassNotFound client.Applet.class. Can someone please expalin? tia.
Originally posted by Keith Lynn: What is the actual name of the applet?
Hello It is Applet. Sorry it is not a good name choice. This is for illustration only. I dont know why I am finding this so difficult. I lost my mind on this today.
posted 14 years ago
I don't think it's a good idea to name it Applet, since Applet.java is a class in the hierarchy of the applet.
posted 14 years ago
Originally posted by Keith Lynn: I don't think it's a good idea to name it Applet, since Applet.java is a class in the hierarchy of the applet.
Hello Yes, however in reality in the actual example it is actually called MyApplet. It lives in applets.jar with the full path of client/MyApplet. What I cant figure out is how to call the class when the html is at the same level as archive/jar and whatever its heirarch is in the archive/jar. As I have it, I believe it should be correct, however it fails and my patience is fried.
The name of the applet doesn't matter here. The problem is that you've put the applet is in WEB-INF. WEB-INF and its subdirectories are for classes and files consumed directly by the web server itself.
Applets don't go there. Applet classes are just plain old files as far as the server is concerned. The web browser requests them by real name, and they are served just as if they were image files, HTML files, etc. The server won't directly serve files from WEB-INF, by design.
Thanks to everyone. The problem was the I couldnt get the packaging striaght in nb5. I finally had to add the jars also as packages so they would be place in the root directory of the webapp.
I now have a further question. How do I write an applet to use a class in an external jar and successfully run in applet viewer or within a webpage. I have imported the external jar classes in the applet, it compiles fine, the external jar is at the same level as the html, it is included in the archive attribute on the applet tag, and still I get the NoClassDefFoundError.
I know this is trival, however I think I have done what is necessary. Can someone point out the missing step? tia