aspose file tools*
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
Author

javax.mail error

Joel Bijapurkar
Greenhorn

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 java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown 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
Bartender

Joined: Oct 14, 2005
Posts: 18888
    
    8

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
Greenhorn

Joined: Aug 01, 2011
Posts: 20

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

 
Consider Paul's rocket mass heater.
 
subject: javax.mail error