This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javax.mail error

 
Joel Bijapurkar
Greenhorn
Posts: 20
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20955
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for my mistake. I did not copy the first line.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic