0

I've been trying to run an executable jar but somehow it returns an error that my class is not existing. I tried to search the web on different ways to run it and I have tried the following so far:

java -cp Unirest.jar:lib/*
java -cp Unirest.jar:/home/appstemp/phuzca/lib/
java -cp Unirest.jar;/home/appstemp/phuzca/lib/*; MainMethod
javac -cp '.:/home/appstemp/phuzca/lib/*.jar' Unirest.jar
javac -cp '.:/home/appstemp/phuzca/lib/*.jar' Unirest
java -cp "Unirest.jar;lib/*" com.unirest.request.MainMethod.java
java -cp "Unirest.jar;lib/*" com.unirest.request.MainMethod
java -cp .:lib/* com.unirest.request.MainMethod
java -classpath lib/*:. com.unirest.request.MainMethod
java -cp "/lib/*:" Unirest.jar
java -cp "/home/appstemp/phuzca/lib/*:" Unirest.jar
java -classpath "/home/appstemp/phuzca/lib/*:." com.unirest.request.MainMethod
java -cp "Unirest.jar;lib/*" com.unirest.request.MainMethod

But none of them worked. Any help would be appreciated

9
  • java -jar Unirest.jar Have you tried this.? Commented Nov 23, 2018 at 6:16
  • yes I did. if I do that, I won't be able to call the external libraries of my jar Commented Nov 23, 2018 at 6:20
  • What exactly do you want to achieve with this executable jar and multiple external library.? Can you explain more so that we can help? Commented Nov 23, 2018 at 6:21
  • you can export the external libraries to the $CLASSPATH and just call the executable jar as java -cp mainclassname Commented Nov 23, 2018 at 6:22
  • 1
    You last attempt was the closest. Always use : as a path entry separator, in operating systems other than Windows. Try java -cp "Unirest.jar:lib/*" com.unirest.request.MainMethod. Commented Nov 23, 2018 at 6:30

1 Answer 1

1

Just posting the answer that was given to me, so everyone can see. Thanks @VGR:

java -cp "Unirest.jar:lib/*" com.unirest.request.MainMethod

Used colon(:) instead of semicolon(;)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.