Home > Mobile >  java -cp Error: Could not find or load main class (java.lang.ClassNotFoundException)
java -cp Error: Could not find or load main class (java.lang.ClassNotFoundException)

Time:05-20

I'm basically following the next tutorial: enter image description here

Any ideas?

CodePudding user response:

Try java -cp "picocli-4.6.3.jar:bashTool-1.0-SNAPSHOT.jar" TestPicoCli --algorithm SHA-1 hello.txt

CodePudding user response:

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 in target/classes

Then, if you are in the folder that contains the TestPicoCli.class, you have to run:

java -cp "<path_to_your_jar>/picocli-4.6.3.jar:bashTool-1.0-SNAPSHOT.jar" TestPicoCli // Without .class

Or if you are in the folder that contains the .jar, you should run:

java -cp "picocli-4.6.3.jar:bashTool-1.0-SNAPSHOT.jar;<path_to_class_file>" TestPicoCli

Note: If you are on Linux, replace ; with :

  • Related