Skip to content

Instantly share code, notes, and snippets.

@GuySawyer
Created October 31, 2017 06:00
Show Gist options
  • Save GuySawyer/fae11b0efefd20927ef029c6b3c6fd4e to your computer and use it in GitHub Desktop.
Save GuySawyer/fae11b0efefd20927ef029c6b3c6fd4e 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