编程知识 cdmana.com

[Java] deploy jar to Ubuntu as a service

1. install jdk

apt install openjdk-11-jdk

2. Create service profile

vim /ect/systemd/system/my_service.service

Add the following

[Unit]
Description=My Java Service
[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/server
ExecStart=/usr/bin/java -jar /home/ubuntu/server/main.jar
SuccessExitStatus=143
TimeoutStopSec=10
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target

3. to update 、 function 、 Start service configuration

systemctl daemon-reload
systemctl enable my_service.service
systemctl start my_service.service

版权声明
本文为[CTi_]所创,转载请带上原文链接,感谢

Scroll to Top