jar中的主类未找到异常

时间:2013-06-10 06:29:41

标签: java jar classpath

我正在尝试根据教程执行performance-meters.jar http://marklogic.github.io/performance-meters/tutorial.html

使用命令

java -cp performance-meters.jar:xcc.jar com.marklogic.performance.PerformanceMeters

我收到以下错误:

D:\MBS\performance-meters-master\performance-meters-master\classes>java -cp performance-meters.jar:xcc.jar com.marklogic.performance.PerformanceMeters
Exception in thread "main" java.lang.NoClassDefFoundError: com/marklogic/performance/PerformanceMeters
Caused by: java.lang.ClassNotFoundException: com.marklogic.performance.PerformanceMeters
        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: com.marklogic.performance.PerformanceMeters.  Program will exit.

我已将两个jar文件保存在同一个文件夹中。

jar文件的链接是: http://developer.marklogic.com/code/performance-meters [http://developer.marklogic.com/products/xcc] [3]

任何帮助都将不胜感激。

2 个答案:

答案 0 :(得分:1)

尝试在cp声明中使用分号代替冒号。

java -cp performance-meters.jar;xcc.jar com.marklogic.performance.PerformanceMeters

答案 1 :(得分:0)

您使用的是Windows系统还是Unix?如果是Windows,我认为你需要使用;而不是:来分隔罐子,如下所示:

java -cp performance-meters.jar ; xcc.jar com.marklogic.performance.PerformanceMeters