I have a Java file that contains an external JAR and I want to run it. It is a simple project: https://github.com/eveningstar33/external-jar and I tested it with Java 8 and also with Java 11. The command to create the class file is javac -cp ./lib/* HelloWorld.java
and it's working, but if I try to run the class using this command: java -cp ./lib/*:./ HelloWorld
it doesn't work and I get this error message:
Error: Could not find or load main class HelloWorld
Caused by: java.lang.ClassNotFoundException: HelloWorld
What should I do to run it? Thank you!
Use java -cp ./lib/* HelloWorld
to run the class.
Update:
If the one given above doesn't work, please try with a ""
i.e. use java -cp "./lib/*" HelloWorld
to run the class.
Another update (tested):
Sorry for posting earlier solutions without testing them myself. Now, I have tested the following to be working:
java -cp .:lib/* HelloWorld
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments