This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 39535
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
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: 24166
    
  30

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: 24166
    
  30

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
 
Similar Threads
How to send mail form java application
If statement problem!!
AuthenticatedFailedException is thrown javamail
java mail
how to send a mail to yahoo user