How to Start Java Jar as Service on Linux


If you have a Java Jar file, you can run it as a service under Linux/Ubuntu.

sudo ln -s /var/www/japi-0.0.1-SNAPSHOT.jar /etc/init.d/japi

Now you can use the default init.d verbs [start,stop,restart,status].

Additionally, init.d also gives the following.

Usage for your new init.d service

Usage: /etc/init.d/japi {start|stop|force-stop|restart|force-reload|status|run}

Start Java Service

sudo /etc/init.d/japi start

Stop Java Service

sudo /etc/init.d/japi stop

Restart Java Service

sudo /etc/init.d/japi restart

Status Information

sudo /etc/init.d/japi status