enes

Enes Altınkaya

How to Create a Linux Service for Your Java Application

How to Create a Linux Service for Your Java Application

You can easily create a systemd service in Linux for your java application.

As shown below you can issue enable command to auto start your java application on boot.

  • cd into /etc/systemd/system
  • open up a text editor
cd /etc/systemd/system
vi listener.service
  • paste following code and edit your jar path
[Unit]
Description=listener
After=syslog.target

[Service]
User=root
ExecStart=/usr/bin/java -jar .......
SuccessExitStatus=143

[Install]
WantedBy=multi-user.target
  • use systemctl enable command to start your service on boot
  • use systemctl start to start your service
systemctl enable listener.service
systemctl start listener.service
Share on