• Post Reply Bookmark Topic Watch Topic
  • New Topic

Trouble fixing NoClassDefFoundError  RSS feed

 
Rob Wehrstein
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code below keeps giving me errors at runtime.


My intention is to send email locally on a Dovecot SMTP server using Postfix. I compile it with the command:

javac SendSmtp.java -cp /usr/share/java/geronimo-javamail-1.4-spec.jar

and run it with the command:

java SendSmtp

but I keep getting the error message:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Session
at SendEmail3.main(SendEmail3.java:15)
Caused by: java.lang.ClassNotFoundException: javax.mail.Session
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more


This is driving me mad! How can I fix this?
 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Posts: 3046
247
Android Chrome Eclipse IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you run the java-program you have to include the jar-file on your classpath, like:



Regards,
Frits
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!