Java -CP错误:找不到或加载Main类(Java.lang.classnotfoundexception)
我基本上要关注下一个教程: https://picococli.info/#_running_running_the_papplication_the_papplication
尝试使用下一个命令运行我的应用程序:
java -cp "picocli-4.6.3.jar:bashTool-1.0-SNAPSHOT.jar" src/main/java/TestPicoCli.java --algorithm SHA-1 hello.txt
我位于一个目录中,其中有2个Jars picocli
和bashtool
,但是我将获得下一个错误消息:
Error: Could not find or load main class src.main.java.TestPr.java
Caused by: java.lang.ClassNotFoundException: src.main.java.TestPr.java
这就是y目录的样子:
有什么想法吗?
I'm basically following the next tutorial: https://picocli.info/#_running_the_application
And I'm trying to run my Application with the next command:
java -cp "picocli-4.6.3.jar:bashTool-1.0-SNAPSHOT.jar" src/main/java/TestPicoCli.java --algorithm SHA-1 hello.txt
I'm located in a directory where I have the 2 jars picocli
and bashTool
, but I'm getting the next error message:
Error: Could not find or load main class src.main.java.TestPr.java
Caused by: java.lang.ClassNotFoundException: src.main.java.TestPr.java
This is how y directory looks like:
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试
java -cp“ picocli-4.6.3.jar:bashtool-1.0-snapshot.jar” testpicocli -algorithm sha-sha-1 hello.txt
Try
java -cp "picocli-4.6.3.jar:bashTool-1.0-SNAPSHOT.jar" TestPicoCli --algorithm SHA-1 hello.txt
命令
java
可以执行编译(字节)Java文件.class
您正在尝试执行源文件
.java
,但这是不正确的。首先,您需要查找
testpicocli.class
文件。它可以由您的IDE生成,并且可能在target/class
中,那么,如果您在包含
testpicocli.class
的文件夹中,则必须运行:或者如果您在包含
.jar
的文件夹中,您应该运行:注意:如果您在Linux上,请替换; 用
> :
The command
java
can execute a compiled (bytecode) Java file.class
You are trying to execute a source file
.java
and it is not correct.First, you need to find the
TestPicoCli.class
file. It could be generated by your IDE and is possibly intarget/classes
Then, if you are in the folder that contains the
TestPicoCli.class
, you have to run:Or if you are in the folder that contains the
.jar
, you should run:Note: If you are on Linux, replace
;
with: