Saturday, May 4, 2024
 Popular · Latest · Hot · Upcoming
13
rated 0 times [  13] [ 0]  / answers: 1 / hits: 135252  / 3 Years ago, thu, november 11, 2021, 11:41:59

I'm trying to run a .jar file on the start up of my Linux machine (Ubuntu 12.04 server)



My script works as long as I run it inside the directory which it is in. If I try to run it outside the directory I get the error "Cannot access jarfile settasks.jar". I suppose my other script is having the same issue.



Is this possibly a script error or a permissions error? I'm completely lost and I have not found anything as of yet to resolve the issue. Any help will be welcomed.


More From » java

 Answers
0

Right click on the file and select Copy.



Now, say you are executing the file using this in the directory with the file in:



java -jar ./settask.jar


Type the beginning of the command (java -jar), and then paste -Ctrl +Shift+V - you should end up with something like this, where is specifies the full path to the file:



java -jar file:///home/wilf/settask/settask.jar


Remove the file:// and press :



java -jar /home/wilf/settask/settask.jar


If it works, then the same command should work in your script.



I hope this answer is OK, I think you are asking about bash scripts.



N.B:



./ tells it the command to search the directory it is currently in.



Havingfile:// at the beginning means it won't work.


[#27958] Saturday, November 13, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
doredtness

Total Points: 153
Total Questions: 113
Total Answers: 106

Location: South Georgia
Member since Fri, Nov 13, 2020
4 Years ago
;