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
Code language: Bash (bash)

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
Code language: Bash (bash)

Stop Java Service

sudo /etc/init.d/japi stop
Code language: Bash (bash)

Restart Java Service

sudo /etc/init.d/japi restart
Code language: Bash (bash)

Status Information

sudo /etc/init.d/japi status
Code language: Bash (bash)

Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments