我正在尝试使用 cmd 运行捆绑在名为 easyflow-gui.jar 的 jar 中的 java 程序:
java -classpath "." -jar easyflow-gui.jar
工作目录是包含所有相关库的目录。
我试图运行的 jar 文件的 Manifest 文件的内容是:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.6.0_32-b27 (Sun Microsystems Inc.)
Main-Class: easyflow.custom.jgraphx.editor.SchemaEditor
这次尝试的结果是:
Exception in thread "main" java.lang.NoClassDefFoundError: com/mxgraph/util/mxEventSource$mxIEventListener
Caused by: java.lang.ClassNotFoundException: com.mxgraph.util.mxEventSource$mxIEventListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: easyflow.custom.jgraphx.editor.SchemaEditor. Program will exit.
问题:实际上找不到哪个类: mxEventSource$mxIEventListener 或主类 easyflow.custom.jgraphx.editor.SchemaEditor ?
编辑1:我检查了文件夹并提取了罐子,发现两个类都可用(捆绑到工作目录中的相应罐子中):
$ls easyflow/custom/jgraphx/editor/SchemaEditor*
easyflow/custom/jgraphx/editor/SchemaEditor$1.class
easyflow/custom/jgraphx/editor/SchemaEditor$2.class
easyflow/custom/jgraphx/editor/SchemaEditor.class
easyflow/custom/jgraphx/editor/SchemaEditor.java
$ls com/mxgraph/util/mxEventSource*
com/mxgraph/util/mxEventSource$mxIEventListener.class
com/mxgraph/util/mxEventSource.class