java.lang.NoClassDefFoundError:从 AIX 运行时出现 javax.mail.Address 错误
我正在尝试在我的 AIX 服务器上运行 java 程序。我编写了
/usr/java6/bin/javac -classpath :.:/usr/jdk/commons-net-3.0.1.jar:/usr/jdk/classes12.jar:/usr/jdk/mysql-connector-java-5.1.17-bin.jar:/usr/jdk/jtds-1.2.5.jar:/urs/jdk/mail.jar:/usr/jdk/joda-time-1.6.2.jar:/usr/jdk/commons-codec-1.4.jar:/usr/jdk/commons-logging-1.1.1.jar:/usr/jdk/httpclient-4.1.1.jar:/usr/jdk/httpclient-cache-4.1.1.jar:/usr/jdk/httpcore-4.1.jar:/usr/jdk/httpmime-4.1.1.jar:/usr/jdk/mailapi.jar:/usr/jdk/pop3.jar:/usr/jdk/smtp.jar:/usr/jdk/dsn.jar:/usr/jdk/imap.jar -d . *.java
似乎可以正确编译的类路径。然后,当我运行该程序时
java daily_transmission
,出现错误 java.lang.NoClassDefFoundError: javax.mail.Address。 Eclipse 之前运行时的所有 .jar 文件都位于 /usr/jdk 文件中。
I am trying to run a java program on my AIX server. I wrote the classpath
/usr/java6/bin/javac -classpath :.:/usr/jdk/commons-net-3.0.1.jar:/usr/jdk/classes12.jar:/usr/jdk/mysql-connector-java-5.1.17-bin.jar:/usr/jdk/jtds-1.2.5.jar:/urs/jdk/mail.jar:/usr/jdk/joda-time-1.6.2.jar:/usr/jdk/commons-codec-1.4.jar:/usr/jdk/commons-logging-1.1.1.jar:/usr/jdk/httpclient-4.1.1.jar:/usr/jdk/httpclient-cache-4.1.1.jar:/usr/jdk/httpcore-4.1.jar:/usr/jdk/httpmime-4.1.1.jar:/usr/jdk/mailapi.jar:/usr/jdk/pop3.jar:/usr/jdk/smtp.jar:/usr/jdk/dsn.jar:/usr/jdk/imap.jar -d . *.java
which seems to compile correctly. Then when I run the program
java daily_transmission
i get the error java.lang.NoClassDefFoundError: javax.mail.Address. All the .jar files that were in Eclipse when it worked before are in the /usr/jdk file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NoClassDefFoundError
意味着(引用相关的 JavaDoc):需要检查两件事:
首先,您的类路径中似乎有一个拼写错误(尽管在编译代码时它不可能存在,否则它不会编译成功,所以这显然不是根路径)您所看到的异常的原因。):
应该是
<预><代码>/usr/jdk/mail.jar
确保您还使用 -classpath 选项将类路径传递给
java
以及javac 拿起那些运行时的
.jar
文件:A
NoClassDefFoundError
means that (quoting the relevant JavaDoc):Two things to check:
Firstly, you appear to have have a typo in your classpath (though it can't have been there when you compiled the code, or it wouldn't have compiled successfully, so that's clearly not the root cause of the exception you're seeing.):
should be
Make sure that you are also using the -classpath option to pass the classpath to
java
as well as tojavac
to pick up those.jar
files at runtime:NoClassDefFoundError 表示 ClassLoader 能够找到该类,但无法加载该类。当有问题的类中的某些静态字段无法初始化时,通常会发生这种情况。所以我确信你的类路径可能是正确的;但该类中的某些静态字段无法正确设置。
NoClassDefFoundError means that the ClassLoader was able to find the class, but it was not able to be loaded. This usually happens when some static field in the offending class could not be initialized. So I am sure that your classpath might be correct; but some static field in that class could not be set correctly.