简体   繁体   English

JavaMail ClassNotFoundException

[英]JavaMail ClassNotFoundException

I am trying to send an email from a Java Application but whenever I run the code found online here我正在尝试从 Java 应用程序发送电子邮件,但是每当我运行此处在线找到的代码时

When I run the code I receive this error:当我运行代码时,我收到此错误:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/MessagingException
    at nameInProgress.Driver.main(Driver.java:69)
Caused by: java.lang.ClassNotFoundException: javax.mail.MessagingException
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 1 more

I'm pretty sure that the problem is relating to how I have attached the source (I am not using maven), I have viewed some other solutions on here, the highest suggests attaching a source code zip, but the link to that file is no longer valid and I cannot find it on my own.我很确定问题与我如何附加源有关(我没有使用 maven),我在这里查看了一些其他解决方案,最高建议附加源代码 zip,但该文件的链接是不再有效,我无法自己找到它。

EDIT: I have created a build path to JavaMail but I am still receiving this error.编辑:我已经创建了 JavaMail 的构建路径,但我仍然收到此错误。

As you stated, you don't have the javax mail jar/dependency.正如您所说,您没有 javax 邮件 jar/依赖项。 If you aren't using a dependency manager then you'll need to get the jar and add it to your classpath.如果您没有使用依赖项管理器,那么您需要获取 jar 并将其添加到您的类路径中。 I found a link for the jar here .我在这里找到了 jar 的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM