java.lang.NoClassDefFoundError: javax/mail/Message

Hi,

I have been trying many demos for JavaMail trying to get it to work after I just installed it now and I'm having configuration problems I believe since I can't get any demo to work all with error:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Message

I went to

http://java.sun.com/products/javamail/

and

http://java.sun.com/products/javabeans/jaf/downloads/index.html

and downloaded and installed JavaMail and JavaBeans Activation Framework. I put mail.jar and activation.jar into my

C:\Program Files\Java\jdk1.5.0_07\jre\lib\ext

so the programs compile now fine.

I have also changed my CLASSPATH a hundred times. Right now it is currently:

.;"C:\Program Files\Java\jre1.5.0_09\lib\ext\QTJava.zip";"C:\Program Files\Java\javamail-1.4\mail.jar";"C:\Program Files\Java\jaf-1.1\activation.jar"

When I try to run the demo that came with JavaMail, I followed the instructions in the README.txt and I can compile msgshow fine, but when I run "java msgshow" I get the error:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException

When I try to run the example I found here:

http://www.javaworld.com/javaworld/jw-10-2001/jw-1026-javamail.html?page=1

I get the error:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Message

If anyone could help me to get rid of this configuration issue and get simple demos to work I would be very grateful!

Michael

[1550 byte] By [KatichMa] at [2007-11-26 17:33:10]
# 1
This exception simply means. class not found.most likely to occur when class file is corrucpted.sudhir nimavat
Sudhir_nimavata at 2007-7-9 0:01:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Which class isn't found or corrupted? Should I download the java mail again?
KatichMa at 2007-7-9 0:01:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

I think it is still a classpath problem.

I ran the build.bat for the webapp demo that came with java mail and I noticed it said:

compiling classes directory

compiling lib directory

javac: invalid flag: Files\Java\jre1.5.0_09\lib\ext\QTJava.zip;C:\Program

Usage: javac <options> <source files>

...

So the problem occurs when it runs this part of the batch file:

javac -classpath "..\docroot\WEB-INF\classes;%CLASSPATH%" demo\*.java

The problem occurs when I have the classpath items surrounded by quotes or not. The space in Program Files is still a problem. I have avoided this problem before and it would be nice if I didn't have to change everything now. Is there anyway to fix this?

Here are the two classpaths I just tried:

.;C:\Program Files\Java\jre1.5.0_09\lib\ext\QTJava.zip;C:\Program Files\Java\javamail-1.4\mail.jar;C:\Program Files\Java\jaf-1.1\activation.jar

.;"C:\Program Files\Jaa\jre1.5.0_09\lib\ext\QTJava.zip";"C:\Program Files\Java\javamail-1.4\mail.jar";"C:\Program Files\Java\jaf-1.1\activation.jar"

KatichMa at 2007-7-9 0:01:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

I copied QTJava.zip, mail.jar, activation.jar into a directory C:\Javatmp and changed the CLASSPATH to:

.;C:\Javatmp\QTJava.zip;C:\Javatmp\mail.jar;C:\Javatmp\activation.jar;C:\Javatmp\servlet-api.jar

and I get a new error below when the build.bat tries to compile the demo:

demo\ListAttachmentsTag.java:46: package javax.servlet.jsp does not exist

followed by a ton of errors.

It's like it doesn't see my servlet-api.jar which is within my C:\Program Files\Java\jdk1.5.0_07\jre\lib\ext directory. I have been compiling servlets fine for quite a while now. I even copied servlet-api.jar into C:\Javatmp and added that to the CLASSPATH as well with no change.

Now what is the problem?

KatichMa at 2007-7-9 0:01:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

I got past that last error. I had to copy jsp-api.jar to my

C:\Program Files\Java\jdk1.5.0_07\jre\lib\ext

directory.

I believe I got it working, the program gave me an error that seemed unrelated to my configuration now.. finally!

I also got this example working!!! It emails! :)

http://www.oracle.com/technology/sample_code/tech/java/jsps/ojsp/sendmail.html

(the top one)

KatichMa at 2007-7-9 0:01:09 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...