eclipse java.lang.NoClassDefFoundError: javax/mail/Address 错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27824571/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.lang.NoClassDefFoundError: javax/mail/Address error
提问by stackuser
I have my project with the mail.jar
in the lib
folder. I created a manifest file as
我的项目mail.jar
在lib
文件夹中。我创建了一个清单文件作为
Manifest-Version: 1.0
Main-Class: mainfile
Class-Path: lib/mail.jar
I then exported the jar
file using eclipse.
然后我jar
使用 eclipse导出文件。
I tried executing the jar file now as java -jar myjar.jar
and I get the error
我现在尝试执行 jar 文件,java -jar myjar.jar
但出现错误
java.lang.NoClassDefFoundError: javax/mail/Address
Any pointers would be greatly appreciated
任何指针将不胜感激
回答by atish shimpi
- Add
mail.jar
in your class path. - Make sure there is no typo in your class path.
- Check exported
jar
file, is all required jar are came there if not you have to use eclipse optionExtract required libraries into generated JAR
.
- 添加
mail.jar
您的课程路径。 - 确保您的类路径中没有拼写错误。
- 检查导出的
jar
文件,如果不是必须使用 eclipse 选项,是否所有必需的 jar 都到了Extract required libraries into generated JAR
。
回答by panagdu
From the Oracle documentation:
从 Oracle文档:
The text file must end with a new line or carriage return. The last line will not be parsed properly if it does not end with a new line or carriage return.
文本文件必须以换行或回车结束。如果最后一行没有以新行或回车结束,则不会正确解析。
So it should look something like this:
所以它应该是这样的:
Manifest-Version: 1.0
Class-Path: lib/mail.jar
Created-By: 1.7.0_06 (Oracle Corporation)
Also, make sure your MANIFEST.MF inside META-INF folder.
另外,请确保您的 MANIFEST.MF 位于 META-INF 文件夹中。
回答by Mahesh
In my case, the classpath was updated and the new classpath was missing mail.jar and activation.jar
就我而言,类路径已更新,新的类路径缺少 mail.jar 和 activation.jar
So linking/copying
所以链接/复制
- mail.jar
- activation.jar
- 邮件文件
- 激活文件
into the classpath lib directory could be one of the solutions.
进入类路径 lib 目录可能是解决方案之一。