Java.lang.NoClassDefFoundError: javax / mail / MessagingException

I worked on a program that uses the Javamail API to send emails based on time events and specific conditions. The program works fine in Eclipse (the latest version), and javamail and activator banners are in the build path, as are javamail dependencies. The problem occurs when I export the project as a jar and try to start it. (The generated stack trace is the same as if the javamail jar was not in the Eclipse build path).

The stack trace is as follows:

`Exception in thread "Timer-1" java.lang.NoClassDefFoundError: javax/mail/MessagingException at SpaceCheck.HourlySpaceAlerts(SpaceCheck.java:212) at WarningReports.run(WarningReports.java:21) at java.util.TimerThread.mainLoop(Unknown Source) at java.util.TimerThread.run(Unknown Source) Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException 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) ... 4 more` 

Thank you for your help.

+7
source share
2 answers

Assuming you put javamail and other dependencies in the lib/ folder relative to the exported jar, you should declare these jars in the manifest file:

 Class-Path: lib/javamail.jar 
+11
source

You can also get Java EE libs by adding one of the software REPOs to this URL.

http://download.eclipse.org/tools/orbit/downloads/

0
source

All Articles