aspose file tools*
The moose likes Applets and the fly likes NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "NoClassDefFoundError" Watch "NoClassDefFoundError" New topic
Author

NoClassDefFoundError

Peter Matthews
Greenhorn

Joined: Nov 07, 2005
Posts: 21
Hi All,

I have a method that sends an email to a recipient, which works well, without it being embedded into an applet, but as soon as I do put it in an applet I get the following error: java.lang.NoClassDefFoundError: javax/mail/MessagingException. Any ideas?

This is my applet code:



This is my class that has the method:



Any help would be very appreciated. I have searched on the net, and have had no luck in finding a solutions.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42906
    
  69
Could it be that the JavaMail jar file is in regular classpath, but that you have not made it accessible to the applet? Applets do not use the classpath a normal application would; you will need to put the jar file into the web directory, togther with the applet files, and reference it in your web page.
graham king
Ranch Hand

Joined: Dec 30, 2004
Posts: 133
Originally posted by Ulf Dittmer:
you will need to put the jar file into the web directory, togther with the applet files, and reference it in your web page.




I'm losing my mind trying to get this to work... Is the web directory the /web-inf/lib?


write, revise, re-write, revise, again...<br />write, revise, re-write, revise, again...
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Originally posted by graham king:




I'm losing my mind trying to get this to work... Is the web directory the /web-inf/lib?


Definitely not! Just the document directory -- the same place as the other applet classes are.


[Jess in Action][AskingGoodQuestions]
graham king
Ranch Hand

Joined: Dec 30, 2004
Posts: 133
Originally posted by Ernest Friedman-Hill:
the same place as the other applet classes are.


can they be put in an .ear?
ear
| | |
main.war main.jar ejb.jar
|
applet.jar main.jar

not sure what to do?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Look at this page, specifically the part near the end about the "archive" attribute. It shows how to put multiple JAR files into an applet tag:

Mohammad Farhat
Ranch Hand

Joined: Nov 17, 2005
Posts: 51
One thing to note about applets is that they make use of the jre rather than the jdk, so make sure, if you have multiple java versions installed (jres and/or jdks) that you are using the same one being used when you're running the application.
This can be checked through the java control panel (can be accessed through control panel->Java plug-in)
Best,
Mohammad
graham king
Ranch Hand

Joined: Dec 30, 2004
Posts: 133
Mohammad, Thanks for all your help!


You know I read your post about your imageio problem and unfortunately I have no help that I can provide, but, I was wondering if you could post an example of detecting the clients jre environment and how one could overwrite an older one with a newer one.

Thanks.

Graham
Mohammad Farhat
Ranch Hand

Joined: Nov 17, 2005
Posts: 51
Graham,
you can detect that by simply changing the html file containing your applet (which now i guess contains an applet tag) using a utility called htmlconverter.exe which comes inside the jdk\bin directory
using this utility would allow you to change the html file into one that would automatically check for the current installed version of jre on the client side, and then would install the version that you specified in the htmlconversion process if an older version is already there
and thanks for offering help..that's okay
Best,
Mohammad
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NoClassDefFoundError