我创建了自己的jar文件,其中包含javamail-1.4.5 lib。当我运行一个启动主类的批处理文件时,我收到了这个错误
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Store
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.privateGetMethodRecursive(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: javax.mail.Store
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 7 more
Press any key to continue . . .
我在批处理文件中使用以下查询
java -cp ../libs/myLib.jar main.Main
奇怪的是,如果我通过eclipse运行我的主课程,我就没有错误。 有人可以帮助我解释为什么会发生这种情况以及我必须做些什么来解决它?
修复:java -cp ../libs/mail.jar;../libs/myLib.jar main.Main