-1

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:

enter image description here

Any ideas?

rasilvap
  • 1,771
  • 3
  • 31
  • 70
  • I just changed the class name :/, that's why I'm using TestPicoCli, in fact in the command I'm using: java -cp "picocli-4.6.3.jar:bashTool-1.0-SNAPSHOT.jar" src/main/java/TestPicoCli --algorithm SHA-1 hello.txt – rasilvap May 19 '22 at 19:34

2 Answers2

1

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

1

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 :

KyreX
  • 106
  • 5
  • I'm getting the same error message with this approach :/ – rasilvap May 19 '22 at 19:50
  • Could you add the relative paths of the jar and class files from where you are executing the command and the command itself? – KyreX May 20 '22 at 04:49
  • for the PiciCli = "/Users/myUser/Documents/picocli/picocli-4.6.3.jar and for the bash= :/Users/rodolfosilva/Documents/picocli/bashLiftTool-1.0-SNAPSHOT. I'm in an Ubuntu Machine – rasilvap May 20 '22 at 15:43
  • 1
    Is the `bashLiftTool` also a jar? I think the easiest way to test it is to copy the `TestPicoCli.class` to `.../picocli/` and **from there** run: `java -cp "picocli-4.6.3.jar:bashTool-1.0-SNAPSHOT.jar" TestPicoCli --algorithm SHA-1 hello.txt`. If this doesn't work, the problem is not with the command. I assume your `TestPicoCli` file has a `main` method – KyreX May 20 '22 at 16:17