[英]java.lang.NoClassDefFoundError: javax/mail/MessagingException
I've been working on a program that uses the Javamail API to send emails based on time events and certain conditions. 我一直致力于使用Javamail API根据时间事件和特定条件发送电子邮件的程序。 The program runs perfectly in Eclipse (newest version) and the javamail and activator jars are in the build path, as are javamail's dependencies.
该程序在Eclipse(最新版本)中运行完美,javamail和激活器jar在构建路径中,javamail的依赖项也是如此。 The problem occurs when I export the project as a jar and try to run it.
当我将项目导出为jar并尝试运行它时,会出现问题。 (The stack trace generated is the same that would be if the javamail jar was missing from the Eclipse build path).
(生成的堆栈跟踪与Eclipse构建路径中缺少javamail jar时的堆栈跟踪相同)。
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. 谢谢您的帮助。
假设您将javamail
和其他依赖项放在相对于导出的jar的lib/
文件夹中,则必须在清单文件中声明这些jar:
Class-Path: lib/javamail.jar
You can also get Java EE libs by adding one of the software REPOs at this url. 您还可以通过在此URL添加一个软件REPO来获取Java EE库。
http://download.eclipse.org/tools/orbit/downloads/ http://download.eclipse.org/tools/orbit/downloads/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.