0

How do i make my .jar file execute on startup because we have constant blackouts here and when the server starts up i want the server.jar to start as well.

Is there any simple way of doing this ?

user294159
  • 29
  • 1
  • 3

1 Answers1

1

Edit the /etc/rc.local file by doing:

sudo nano /etc/rc.local

And in there type

java -jar /path/to/your/file.jar

Make sure this goes BEFORE the 'exit 0'

Mitch
  • 4,637
  • 3
  • 24
  • 33
  • Hi ive done this already, it does not work. – user294159 Jun 26 '14 at 14:00
  • does `java -jar /path/to/your/file.jar` normally work? – Mitch Jun 26 '14 at 14:07
  • Yes, well the command i use while logged in with putty is nohup java -jar /path/to/file/file.jar & then it works perfectly fine. – user294159 Jun 26 '14 at 14:17
  • Try adding that exact command to the file, and see if that works for you – Mitch Jun 26 '14 at 14:17
  • Also same result doesn't work, because its a basic network app so when i run the command it works but doesn't start up. – user294159 Jun 26 '14 at 14:31
  • As a diagnostic step, before the nohup... line add the line 'ifconfig'. Tell me if you have an IP and connectivity at that point. Also, consider some of the answers here: http://askubuntu.com/questions/99232/how-to-make-a-jar-file-run-on-startup-and-when-you-log-out?rq=1, particularly `upstart` – Mitch Jun 26 '14 at 14:34
  • Yes there is connectivity ip 192.168.1.101 it's static set it myself. – user294159 Jun 26 '14 at 14:55