Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 982
  • Last Modified:

How can I resolve NoClassDefFoundError in javax/mail Windows application?

I'm writing a standalone Windows XP command line application. It compiles OK but gets a NoClassDefFoundError for javax/mail/Address. My code does not use the Address class itself, but it does use the InternetAddress class.
Is this a jar problem? What jars do I need, and where should they be put?
Thanks for your thoughts.
0
RBEyestone
Asked:
RBEyestone
  • 3
  • 2
  • 2
2 Solutions
 
RBEyestoneAuthor Commented:
I'm still looking for a solution - it seems like this should be just a matter of getting the right things in the right places?
0
 
Bart CremersJava ArchitectCommented:
The class could be in several jar files:
- mail.jar
- j2ee.jar
- javaee.jar

depending on what you got installed.

There are different ways of getting this jar file loaded, but I find it safest and most future proof to simply define the classpath when running your program:

java -classpath .;<path-to>\javaee.jar <name-of-your-class>
0
 
shaz_Commented:
java standard api does not come with the mail.jar file... u need to download it manually and put it in  your java/jdk1.6.X_XX/jre/lib folder...

download it here
http://java.sun.com/products/javamail/
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
RBEyestoneAuthor Commented:
The solution I came up with, based on comments I found elsewhere (not on this exchange), was to put both mail.jar and activation.jar in jrel.5.0_10\lib\ext. All classes can now be found. There are still runtime problems, but those are for another post.
Thanks to everyone for your suggestions.
0
 
shaz_Commented:
well no one suggested activation jar because u didnt post any errors with activation... u were having noclassfounderrors with classes from the mail package.. which ppl here suggested u put in your lib folder
0
 
Bart CremersJava ArchitectCommented:
To elaborate a bit on the chosen solution (self found), it's one of the "different ways" I mentioned in my post, but I chose to give the solution I like best. In the past I've run in to problems with copying jar files to the lib/ext folder or your JRE installation:

1. Installing a newer JRE requires you to remember the copied jars. Your application will suddenly stop running and it will take a while to find out why.
2. Running another application depending on a different version of an external library with the same JRE will not work.
   You'll have to define the classpath there for sure


0
 
RBEyestoneAuthor Commented:
Thanks to both of you for your extended comments. And thanks for the pointer re proper manners on the E-E.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now