views:

64

answers:

2

Hi

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.

+1  A: 

Use the absolute path to your JAR file, e. g. /root/jobs/job.jar.

joschi
A: 

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
Colin Hebert