How do I create a Ubuntu terminal script that will open a .jar file?

This is what I have tried until now:

java -jar "/home/my-name/Desktop/Slow but Accurate/BulkNameChecker-slowbutaccurate.jar"

But it returns

Error: Unable to access jarfile /home/my-name/Desktop/Slow but Accurate/BulkNameChecker-slowbutaccurate.jar

  • try this if Java installed :java -jar Desktop/"Slow but Accurate"/BulkNameChecker-slowbutaccurate.jar or use cd command until you reach the Slow but Accurate folder and write java -jar BulkNameChecker-slowbutaccurate.jar – Black Block Apr 2 '12 at 17:48
  1. your java started correctly (error message is from java)
  2. java does not see that jar file.

I bet that if you do:

ls "/home/my-name/Desktop/Slow but Accurate/BulkNameChecker-slowbutaccurate.jar"

you will get:

ls: /home/my-name/Desktop/Slow but Accurate/BulkNameChecker-slowbutaccurate.jar: No such file or directory

so you can try:

ls "/home/"
ls "/home/my-name/"
ls "/home/my-name/Desktop/"
ls "/home/my-name/Desktop/Slow but Accurate/"
ls "/home/my-name/Desktop/Slow but Accurate/*.jar"
ls "/home/my-name/Desktop/Slow but Accurate/BulkNameChecker-slowbutaccurate.jar"


find "/home/my-name" -name "*.jar"

to determine correct path.

Note1: you can use tab to assist you while typing a file names in terminal It is very handy.

Note2: If you use encrypted file system, or mounted when logged in and trying to run this script as another user, then the jar file might not be accessible, but most probable reason is a typo in the filename.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.