Reputation: 9404
I used a shell script to run a Java class. My script contains
#!/bin/sh
java -jar jobs/job.jar
These are my failed attempts to run it.
[root@]#sh testapp.sh
Unable to access jarfile jobs/job.jar
if I just do this at the command line it works fine
[root@]#java -jar jobs/job.jar
thanks.
Upvotes: 6
Views: 20392
Reputation: 93187
The best way is to get the current dirname and get in there with this:
#!/bin/sh
cd `dirname "$0"`
java -jar ./job/job.jar
Upvotes: 7