Is there a command to make it. I'm trying to run a .jar file with linux boot and make it run all the time.
Asked
Active
Viewed 556 times
0
-
Which version of Ubuntu are you using? – user68186 Jan 08 '21 at 13:49
-
Ubuntu 16.04 Xenial – xdpwq10 Jan 08 '21 at 14:09
-
Gentle reminder: Ubuntu 16.04 will reach End Of Life soon. Time to think about migrating to a newer release of Ubuntu. – user535733 Jan 08 '21 at 16:11
1 Answers
2
Create a file in /lib/systemd/system
. Its name must end with .service
. For example myfirst.service
.
Find the full absolute path to java using which java
In the file put the following.
[Unit]
Description=Job that runs the foo.jar
[Service]
ExecStart=/full/path/to/java -jar /full/path/to/.jar
[Install]
WantedBy=multi-user.target
Enable it to run at boot:
sudo systemctl enable myfirst
Also refer to this answer for further clarification

A.Sha
- 576
- 3
- 13