user2612619
user2612619

Reputation: 1129

Jar not running

So I created a script the the following commands

#! /usr/bin/sh

    PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
    JAVA=/usr/bin/java
    MY_SERVER=/home/user/Desktop/Hello.jar
    USER=user
    /bin/su - $USER -c "$JAVA -jar $MY_SERVER &"

And I saved it in

etc/init.d/

And then ran the following command in terminal

sudo update-rc.d java_server_launch.sh defaults

I have a program located at

/home/user/Desktop/

And it is called Hello.jar and it works fine when I run it. When I restart my computer for some reason the program (Hello.jar) does not execute. What am I doing wrong?

I'm doing exactly what the answer here says.

Upvotes: 2

Views: 267

Answers (2)

MultiplyByZer0
MultiplyByZer0

Reputation: 7109

You need to replace Hello.jar with $MY_SERVER in the last line of your bash script. That's because your current working directory isn't /home/user/Desktop

Edit: Try replacing the last line of code with this:

/bin/su $USER -c "$JAVA -jar $MY_SERVER &"

Upvotes: 2

Guy Gavriely
Guy Gavriely

Reputation: 11396

if you're running on Ubuntu you should check out upstart

see how simple it is to run jar https://stackoverflow.com/a/12102542/41576

Upvotes: 0

Related Questions