File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes javamail Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "javamail" Watch "javamail" New topic


Amanda Weber

Joined: Nov 20, 2002
Posts: 28
I am trying to email from a java program. I set everything as the sun tutorial said and when I ran the program I get a NoClassDefFound: javax/mail/Session. What should I do about it?
Philip Shanks
Ranch Hand

Joined: Oct 15, 2002
Posts: 189
DISCLAIMER: I haven't actually tried this, so my answer could be totally wrong!
I don't think that javax.mail.* is part of the standard J2SE 1.4 distribution, so this error probably means that you don't have the right classes in your classpath.
The easiest way to remedy this is to go to the Java Mail homepage and download the API implementation (~2.2Mb). Once you have this, you will find inside about 4 or 5 jar files. The easiest way to get these into your classpath is to copy them into the "JAVA_HOME/jre/lib/ext" directory. "JAVA_HOME" is wherever you installed Java on your particular platform.
Of course, this is a rather brute forece soltion, and of course there is more to this API than those few jar's, but this should get you started.
UPDATE: In reading the homepage info, I see that you will also need the JavaBeans Activation Framework. It is probably installed in much the saem way I describe above.
[ November 20, 2002: Message edited by: Philip Shanks ]

Philip Shanks, SCJP - Castro Valley, CA
My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
Amanda Weber

Joined: Nov 20, 2002
Posts: 28
I did all that already and this is what happends AFTER I follow all of Sun's instructions.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please edit your profile and select a new name which meets the requirements.
Please change your display name soon! Invalid accounts get deleted, and I think yours would be deleted sooner rather than later...
I agree. Here's the link:
subject: javamail
It's not a secret anymore!