Solved

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

Posted on 2008-06-18
8
972 Views
Last Modified: 2013-11-19
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
Comment
Question by:RBEyestone
  • 3
  • 2
  • 2
8 Comments
 

Author Comment

by:RBEyestone
ID: 21905169
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
 
LVL 13

Expert Comment

by:Bart Cremers
ID: 21905224
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
 
LVL 3

Expert Comment

by:shaz_
ID: 21906009
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:RBEyestone
ID: 21960114
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
 
LVL 3

Assisted Solution

by:shaz_
shaz_ earned 60 total points
ID: 21961348
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
 
LVL 13

Accepted Solution

by:
Bart Cremers earned 65 total points
ID: 21970723
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
 

Author Closing Comment

by:RBEyestone
ID: 31468665
Thanks to both of you for your extended comments. And thanks for the pointer re proper manners on the E-E.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
stackato and cloud 4 74
diffSum example 4 27
factorial example 4 35
Chrome: Need to display Favorites' URL icons in the task bar 4 20
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now