简体   繁体   中英

JavaMail ClassNotFoundException

I am trying to send an email from a Java Application but whenever I run the code found online here

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.

EDIT: I have created a build path to JavaMail but I am still receiving this error.

As you stated, you don't have the javax mail jar/dependency. If you aren't using a dependency manager then you'll need to get the jar and add it to your classpath. I found a link for the jar here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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