Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save linpan0/d1e4cc624e4e9d5ac3813a5c3cbc6378 to your computer and use it in GitHub Desktop.
Save linpan0/d1e4cc624e4e9d5ac3813a5c3cbc6378 to your computer and use it in GitHub Desktop.
Raspberry Pi 3 - Starting a Java JAR on Boot using systemd
Jessie has moved away from sysvinit and onto systemd. Writing an init script to /etc/init.d/ is outdated,
and a bit tedious since you have to handle the start/stop/restart logic yourself (if you want those capabilities).
New Method:
1. Write a unit file for systemd.
$ sudo nano /etc/systemd/system/your_jar_software.service
[Unit]
Description=Example on starting a JAR with systemd
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/java -jar /home/pi/path/to/your/JAR.jar
[Install]
WantedBy=multi-user.target
2. Start it at boot
$ sudo systemctl enable your_jar_software
3. Manually control it
$ sudo systemctl start|stop|status|restart your_jar_software
4. Observe the output
$ sudo journalctl -u your_jar_software
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment