我创建一个使用send mail的java应用程序,当我运行时它在eclipse中工作。但是当我把它变成jar并在终端中运行时(我正在使用Ubuntu)java -jar EmailApp.jar
它会给出以下错误:
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Authenticator
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)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: javax.mail.Authenticator
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
我的 META-INF / MANIFEST.MF :
Manifest-Version: 1.0
Main-Class: com.abc.client.xyz.EmailSender
Class-Path: lib/javax.mail-1.3.3.01.jar
lib/mail-1.4.7.jar
lib/activation-1.1.1.jar
lib/commons-logging-1.1.jar
lib/log4j-1.2.12.jar
lib/commons-collections.jar
lib/commons-dbcp-1.2.1.jar
lib/commons-dbutils-1.0.jar
lib/commons-email-1.1.jar
lib/commons-io.jar
lib/commons-lang-2.5.jar
lib/commons-pool-1.2.jar
lib/commons-pool-20030825.183949.jar
lib/jtds-1.2.5.jar
lib/mysql-connector.jar
lib/idc-dgps4-egn-1.0-SNAPSHOT.jar
$ ls -al ./lib
total 17100
drwxrwxr-x 2 xyz xyz 4096 Oct 7 15:21 .
drwxrwxr-x 10 xyz xyz 4096 Oct 7 14:26 ..
-rw-rw-r-- 1 xyz xyz 69409 Oct 5 19:20 activation-1.1.1.jar
-rw-rw-r-- 1 xyz xyz 575389 Oct 16 2014 commons-collections.jar
-rw-rw-r-- 1 xyz xyz 107631 Oct 16 2014 commons-dbcp-1.2.1.jar
-rw-rw-r-- 1 xyz xyz 26687 Oct 16 2014 commons-dbutils-1.0.jar
-rw-rw-r-- 1 xyz xyz 30651 Oct 16 2014 commons-email-1.1.jar
-rw-rw-r-- 1 xyz xyz 52543 Oct 16 2014 commons-exec-1.1.jar
-rw-rw-r-- 1 xyz xyz 83613 Oct 16 2014 commons-io.jar
-rw-rw-r-- 1 xyz xyz 279193 Oct 16 2014 commons-lang-2.5.jar
-rw-rw-r-- 1 xyz xyz 52915 Oct 16 2014 commons-logging-1.1.jar
-rw-rw-r-- 1 xyz xyz 42492 Oct 16 2014 commons-pool-1.2.jar
-rw-rw-r-- 1 xyz xyz 38815 Oct 16 2014 commons-pool-20030825.183949.jar
-rw-rw-r-- 1 xyz xyz 865430 Oct 16 2014 idc-dgps4-egn-1.0-SNAPSHOT.jar
-rw-rw-r-- 1 xyz xyz 355030 Jul 11 2015 javax.mail-1.3.3.01.jar
-rw-rw-r-- 1 xyz xyz 708951 Oct 16 2014 js-1.6R5.jar
-rw-rw-r-- 1 xyz xyz 302284 Oct 16 2014 jtds-1.2.5.jar
-rw-rw-r-- 1 xyz xyz 358085 Oct 16 2014 log4j-1.2.12.jar
-rw-rw-r-- 1 xyz xyz 521157 Oct 7 15:20 mail-1.4.7.jar
-rw-rw-r-- 1 xyz xyz 397032 Sep 29 11:06 mysql-connector.jar
-rw-rw-r-- 1 xyz xyz 12598097 Oct 16 2014 tools.jar
注意:/ lib文件夹中的所有.Jar文件。
我的申请结构:
请帮助我。