我试图在这里运行示例程序http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-java.html 这是命令输出......
...
tab_a INNER JOIN tab_b
ON UNIX_TIMESTAMP(tab_a.datetime)=tab_b.seconds_since_epoch
我尝试使用此搜索字符串向Google寻求答案......
$ java AmazonSESSample -cp "javamail-1.4.3/mail.jar"
java.lang.NoClassDefFoundError: javax/mail/Address
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
atsun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: javax.mail.Address
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main"
我在搜索结果中没有看到任何有用的东西: - (
有什么想法吗?
答案 0 :(得分:0)
我认为您指出的JAR文件(javamail-1.4.3/mail.jar
)未找到..
java AmazonSESSample -cp "javamail-1.4.3/mail.jar"
尝试提供如下所示的完整路径(下面仅为示例)
java AmazonSESSample -cp "/usr/lib/javamail-1.4.3/mail.jar"
更新:在Windows上尝试以下
java AmazonSESSample -classpath "C:\Users\MichaelDocuments\GitHub\guesstimate\scratch\javamail-1.4.3\mail.jar"
答案 1 :(得分:0)
好的答案是,classpath选项是在主类之后。所以-cp和jar值作为'args'传递给'main'方法 - doh !!!!!!!!!!!!!! 只需按下图所示移动此选项,就会加载jar并按预期找到类。 这个令人沮丧的难题的一个有用的结果是我发现了'-verbose:class',这对未来的其他问题很有用我确定:)
$ java -verbose:class -cp '.;mail.jar' AmazonSESSample | grep Session
[Loaded javax.mail.Session from file:/C:/Users/Michael/Documents/GitHub/guesstimate/scratch/mail.jar]
[Loaded javax.mail.Session$1 from file:/C:/Users/Michael/Documents/GitHub/guesstimate/scratch/mail.jar]
[Loaded javax.mail.Session$3 from file:/C:/Users/Michael/Documents/GitHub/guesstimate/scratch/mail.jar]
[Loaded javax.mail.Session$5 from file:/C:/Users/Michael/Documents/GitHub/guesstimate/scratch/mail.jar]
[Loaded javax.mail.Session$4 from file:/C:/Users/Michael/Documents/GitHub/guesstimate/scratch/mail.jar]
[Loaded javax.mail.Session$2 from file:/C:/Users/Michael/Documents/GitHub/guesstimate/scratch/mail.jar]
Michael@mikeToshSpare /cygdrive/c/Users/Michael/Documents/GitHub/guesstimate/scratch
$ java -verbose:class AmazonSESSample -cp '.;mail.jar' | grep Session
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Session
at AmazonSESSample.main(AmazonSESSample.java:56)
Caused by: java.lang.ClassNotFoundException: javax.mail.Session
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more