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

javax.mail error

Joel Bijapurkar

Joined: Aug 01, 2011
Posts: 20

I am using the following code to send an email using java:

I get the following error when I try to run the program:

Error: Could not find main class Demo.SendMailDemo
Exception in thread "main" java.lang.NoClassDefFoundError: Demo.SendMailDemo
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Demo.SendMailDemo
at$ Source)
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more

I am using the Eclipse IDE and I have also included the mail.jar and the activation.jar file in the class path using the Add External Jars option in the Java Build Path window.
I also tried changing the file name but the results are the same. Why am I getting this error and how do I remove it?
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Why are you trying to run class "Demo.SendMailDemo" when your SendMailDemo class isn't in the "Demo" package?

This is just classpath-setting for beginners, it isn't anything to do with JavaMail, so I will move your post to the Beginning Java forum.
Joel Bijapurkar

Joined: Aug 01, 2011
Posts: 20

Sorry for my mistake. I did not copy the first line.

I agree. Here's the link:
subject: javax.mail error
It's not a secret anymore!