I'm trying to run my app as a daemon/service on a Debian distro via systemd. Here is my service file:

Description=MyApp Service

ExecStart=sudo /usr/bin/java -jar /home/pi/myapp.jar


I copy that to /lib/systemd/system/myapp.service. I then run:

sudo systemctl enable myapp

I then check the status:

sudo systemctl status myapp

And I see these errors:

● myapp.service - MyApp Service
   Loaded: error (Reason: Invalid argument)
   Active: inactive (dead)

Sep 29 09:56:24 raspberrypi systemd[1]: [/lib/systemd/system/myapp.service:8] Executable path is not absolute, ignoring: sudo /usr/bin/java -jar /home/pi/myapp.jar
Sep 29 09:56:24 raspberrypi systemd[1]: myapp.service: Service lacks both ExecStart= and ExecStop= setting. Refusing.

When I do which java I see:

pi@raspberrypi:/lib/systemd/system $ which java

So I'm not understanding why systemd is complaining about the executable path. Any ideas how I can troubleshoot?

1 Answer 1


The sudo path is not absolute. If your systemd unit is a system unit, the sudo shouldn't be necessary anyway, since system units are run as root by default.

EDIT: instead of running the JVM and the whole Java application as root, it would probably be better to run the service as an unprivileged user. If the application needs some capability not normally granted to unprivileged users, it can be added with the AmbientCapabilities setting. For example, by adding the following lines to the [Service] section:


the service is run as user nobody but is granted the CAP_SYS_RAWIO capability.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .