java.lang.NoClassDefFoundError:javax / mail / MessagingException [英] java.lang.NoClassDefFoundError: javax/mail/MessagingException

查看:1602
本文介绍了java.lang.NoClassDefFoundError:javax / mail / MessagingException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直致力于使用Javamail API根据时间事件和特定条件发送电子邮件的程序。该程序在Eclipse(最新版本)中运行完美,javamail和激活器jar在构建路径中,javamail的依赖项也是如此。当我将项目导出为jar并尝试运行它时,会出现问题。 (生成的堆栈跟踪与Eclipse构建路径中缺少javamail jar时的堆栈跟踪相同)。

I've been working on a program that uses the Javamail API to send emails based on time events and certain conditions. The program runs perfectly in Eclipse (newest version) and the javamail and activator jars are in the build path, as are javamail's dependencies. The problem occurs when I export the project as a jar and try to run it. (The stack trace generated is the same that would be if the javamail jar was missing from the Eclipse build path).

堆栈跟踪如下:

`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`

谢谢你的帮助。

推荐答案

假设您将 javamail 和其他依赖项放入 lib / 相对于导出的jar的文件夹,你必须在清单文件中声明这些jar:

assuming you put javamail and other dependencies in to lib/ folder relative to your exported jar, you have to declare those jars in manifest file:

Class-Path: lib/javamail.jar

这篇关于java.lang.NoClassDefFoundError:javax / mail / MessagingException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆