Upload the jar package to the directory you want
Such as /java/service/demo.jar
Go to the /etc/systemd/system directory
Create demo.service
The content is as follows
----------------------------------------------------
[Unit]
Description=wechat
After=syslog.target network.target
[Service]
Type=simple
ExecStart=/usr/bin/java -jar /java/service/demo.jar
ExecStop=/bin/kill -15 $MAINPID
User=root
Group=root
[Install]
WantedBy=multi-user.target
---------------------------------------------------
systemctl start demo.service starts the service
systemctl enable boot self-start
systemctl disable to stop self-starting at boot
systemctl status View status
systemctl restart restarts the service