java.lang.NoClassDefFoundError:从 AIX 运行时出现 javax.mail.Address 错误

发布于 2024-11-28 11:16:02 字数 752 浏览 4 评论 0原文

我正在尝试在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

嘦怹 2024-12-05 11:16:02

NoClassDefFoundError意味着(引用相关的 JavaDoc)

如果 Java 虚拟机或类加载器实例尝试
加载类的定义(作为正常方法调用的一部分或
作为使用 new 表达式创建新实例的一部分)并且没有
可以找到类的定义。

当前执行时搜索到的类定义已存在
类已编译,但无法再找到定义。

需要检查两件事:

  1. 首先,您的类路径中似乎有一个拼写错误(尽管在编译代码时它不可能存在,否则它不会编译成功,所以这显然不是根路径)您所看到的异常的原因。):

    <代码>/urs/jdk/mail.jar
    

    应该是

    <预><代码>/usr/jdk/mail.jar

  2. 确保您还使用 -classpath 选项将类路径传递给 java 以及 javac 拿起那些运行时的 .jar 文件:

    java -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 /j tds-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/公共日志ing-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/ j dk/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每日传输
    

A NoClassDefFoundError means that (quoting the relevant JavaDoc):

Thrown if the Java Virtual Machine or a ClassLoader instance tries to
load in the definition of a class (as part of a normal method call or
as part of creating a new instance using the new expression) and no
definition of the class could be found.

The searched-for class definition existed when the currently executing
class was compiled, but the definition can no longer be found.

Two things to check:

  1. 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.):

    /urs/jdk/mail.jar
    

    should be

    /usr/jdk/mail.jar
    
  2. Make sure that you are also using the -classpath option to pass the classpath to java as well as to javac to pick up those .jar files at runtime:

    java -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 daily_transmission
    
呆头 2024-12-05 11:16:02

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文