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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 22:19:13  来源:igfitidea点击:

java.lang.NoClassDefFoundError: javax/mail/Address error

javaeclipsejar

提问by stackuser

I have my project with the mail.jarin the libfolder. I created a manifest file as

我的项目mail.jarlib文件夹中。我创建了一个清单文件作为

Manifest-Version: 1.0
Main-Class: mainfile
Class-Path: lib/mail.jar

I then exported the jarfile using eclipse.

然后我jar使用 eclipse导出文件。

I tried executing the jar file now as java -jar myjar.jarand I get the error

我现在尝试执行 jar 文件,java -jar myjar.jar但出现错误

java.lang.NoClassDefFoundError: javax/mail/Address

Any pointers would be greatly appreciated

任何指针将不胜感激

回答by atish shimpi

  1. Add mail.jarin your class path.
  2. Make sure there is no typo in your class path.
  3. Check exported jarfile, is all required jar are came there if not you have to use eclipse option Extract required libraries into generated JAR.
  1. 添加mail.jar您的课程路径。
  2. 确保您的类路径中没有拼写错误。
  3. 检查导出的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

所以链接/复制

  1. mail.jar
  2. activation.jar
  1. 邮件文件
  2. 激活文件

into the classpath lib directory could be one of the solutions.

进入类路径 lib 目录可能是解决方案之一。