我正在尝试从我的源创建一个 JAR 文件,但是当我运行它时,我得到类未找到异常 - 它找不到主类,即使我在 MANIFEST.MF 文件中定义了它。你能发现任何错误吗?
我的 JAR 结构:
META-INF/
META-INF/MANIFEST.MF
main/
main/java/
main/java/ThreadWatcher.java
main/java/WatcherObject.java
main/resources/
main/resources/WatcherObjectType.java
main/resources/TLogger.java
main/resources/DataProvider.java
main/resources/WatcherObjectStatus.java
main/resources/SettingsProvider.java
main/java/WatcherObject.java 包含主要方法。
我的清单.MF:
Manifest-Version: 1.0
Created-By: 1.6.0_27 (Sun Microsystems Inc.)
Main-Class: main.java.ThreadWatcher
当我运行它时,我得到:
Exception in thread "main" java.lang.NoClassDefFoundError: main/java/ThreadWatcher
Caused by: java.lang.ClassNotFoundException: main.java.ThreadWatcher
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
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)
Could not find the main class: main.java.ThreadWatcher. Program will exit.
感谢帮助!