Java 命令行错误(无法找到或加载主类)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23689234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java command line error (could not find or load main class)
提问by DSF
When attempting to run the below command:
尝试运行以下命令时:
java -classpath mycompanychecks.jar:checkstyle-5.7-all.jar \
com.puppycrawl.tools.checkstyle.Main \
-c config.xml -r .
I get the error:
我收到错误:
Error: Could not find or load main class \
In the directory that I'm running the command from I do have the two jar files, and also I have checked that 'com.puppycrawl.tools.checkstyle.Main
' does in fact reside in the 'checkstyle-5.7-all.jar
'. As the error seems to refer to the backslash maybe it's a syntactical error? However I'm executing the command exactly as stated on the checkstyle page.
在我运行命令的目录中,我确实有两个 jar 文件,并且我还检查了“ com.puppycrawl.tools.checkstyle.Main
”确实驻留在“ checkstyle-5.7-all.jar
”中。由于错误似乎是指反斜杠,所以它可能是一个语法错误?但是,我正在完全按照checkstyle 页面上的说明执行命令。
采纳答案by peter.petrov
This example you're trying is clearly not about Windows.
您正在尝试的这个示例显然与 Windows 无关。
Check here:
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html
在这里查看:http:
//docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html
You need to use ;
as separator to say the least.
;
至少可以说,您需要用作分隔符。
So you need something like this (this is all one line).
所以你需要这样的东西(这都是一行)。
java -classpath c:\test\mycompanychecks.jar;c:\test\checkstyle-5.7-all.jar com.puppycrawl.tools.checkstyle.Main -c config.xml -r .
java -classpath c:\test\mycompanychecks.jar;c:\test\checkstyle-5.7-all.jar com.puppycrawl.tools.checkstyle.Main -c config.xml -r .