我能够编译代码,但在运行时却抛出了未找到的类
C:\Users\Desktop\New>javac -classpath java-mail-1.4.4.jar SendMail.java
C:\Users\Desktop\New>java -classpath java-mail-1.4.4.jar SendMail
Exception in thread "main" java.lang.NoClassDefFoundError: SendMail
Caused by: java.lang.ClassNotFoundException: SendMail
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: SendMail. Program will exit.
你能建议如何解决这个问题吗?
答案 0 :(得分:1)
尝试使用以下命令
编译java类
javac -classpath .;<jar file path>; Abc.java
执行java类
java -classpath .;<jar file path>; Abc
答案 1 :(得分:0)
尝试使用:
<强>窗强>
java -classpath java-mail-1.4.4.jar;. SendMail
note this ----^