I want to run a simple executable jar like this:
java -jar /path/to/my/jar/myjar.jar
However, i have to put that absolute path every time I want to run it. Is there a way to tell the OS to look for the jar in $PATH environment variable?
You can also copy your jar file to /usr/bin folder, then it will work with just $ myjar.jar
Make sure your jar file has the executable bit (chmod +x myjar.jar) and copy it to /usr/bin (sudo cp myjar.jar /usr/bin/myjar.jar)
I think you'd use the classpath; append your directory to it and java -jar myjar.jar should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With