简体   繁体   English

centos 6.2不存在javax.mail软件包

[英]package javax.mail does not exist for centos 6.2

I have a centos 6.2 server. 我有一个centos 6.2服务器。 I have put the mail.jar into /usr/java/jdk1.7.0_03/jre/lib/ext folder. 我已将mail.jar放入/usr/java/jdk1.7.0_03/jre/lib/ext文件夹中。 Then when I compile my java it gives me this error. 然后,当我编译Java时,它给了我这个错误。 The funny part I have done this last month on another server also with centos 6.2 and same java version all works fine. 我上个月在另一台使用centos 6.2和相同Java版本的服务器上完成此操作的有趣部分都可以正常工作。 What could be missing here? 这里可能缺少什么?

package javax.mail does not exist
import javax.mail.Message;

Make sure your program is using the java in that jdk you put the mail.jar file in. This type of setup only works if you are using java.exe from the path you put the jar in. It's harder to maintain this because you have to remember to copy that jar if you ever update the jdk. 确保您的程序在放入mail.jar文件的那个jdk中使用的是Java。只有在您从放置jar的路径中使用java.exe时,这种类型的设置才有效。由于您拥有要记住,如果您更新过jdk,请复制该jar。 You really just need to make sure mail.jar is in the classpath of the class that needs it. 您实际上只需要确保mail.jar位于需要它的类的类路径中。 If you jar it up with your program then you just add it to the classpath in your manifest file in the jar. 如果将其与程序一起打包,则只需将其添加到jar清单文件中的类路径中即可。 If you do not use a jar, another option is passing it in on the command line. 如果您不使用jar,则另一个选择是在命令行中传递它。

Ex. 防爆。 java -classpath=c:\\temp\\mail.jar myclass java -classpath = c:\\ temp \\ mail.jar myclass

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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