• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

simple applet difficulties

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the actual name of the applet?
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Keith Lynn
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
have you tried different paths in your CODEBASE parameter?

For example try using "./" instead of just "."

If that doesn't work, try hardcoding the path during the testing phase. It will help you avoid the burnout and frustration.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

So if your applet tag is

<APPLET codebase="." code="client.Applet.class" archive="applets.jar" width=350 height=200></APPLET>

and the applet is embedded in a JSP whose URL is, say

http://myserver.com/products/foo.jsp

then the browser is going to ask for

http://myserver.com/products/applets.jar

and so applets.jar goes at the top level of the "products" webapp.
 
Chris Pat
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
The harder I work, the luckier I get. -Sam Goldwyn So tiny. - this ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic