Configuring Jetty as a service - how?

by Trollhorn   Last Updated August 14, 2019 20:00 PM

As I'm using Debian, and as the packages in the package manager aren't quite up-to-date, I'm forced to do a manual installation.

I downloaded the latest version as a .tar.gz file, and extracted it to /opt. Now I'm unsure on what to do next.

I need to have Jetty run as a service on startup, for every user on this PC. But how? I couldn't find anything in the documentation.

Answers 4

There should be a script into the bin directory. I don't know if it works under Debian, but it should be a good starting point.

Sebastiano Pilla
Sebastiano Pilla
April 20, 2011 15:10 PM

If you can not find just download last one

And save it to /etc/init.d/jetty

Also you may need to edit /etc/default/jetty to set your individual settings like:


If you want service start after reboot do not forget add it to default startup level with update-rc.d

April 20, 2011 15:58 PM

For CentOS 7 Linux I have downloaded the latest Jetty distribution and created the file /etc/systemd/system/jetty.service:


ExecStart=/usr/bin/java -jar /usr/share/java/jetty-distribution-9.3.10.v20160621/start.jar jetty.home=/usr/share/java/jetty-distribution-9.3.10.v20160621 jetty.base=/var/www/jetty jetty.http.port=8080
ExecStop=/bin/kill ${MAINPID}


Then I have run the commands to create the user and the base dir:

# useradd -s /sbin/nologin jetty

# java -jar /usr/share/java/jetty-distribution-9.3.10.v20160621/start.jar \
      jetty.home=/usr/share/java/jetty-distribution-9.3.10.v20160621 \
      jetty.base=/var/www/jetty \

# chown -R jetty.jetty /var/www/jetty

Then I have activated the new service:

# systemctl enable jetty

# systemctl start jetty

And finally checked the logs:

# systemctl status -l jetty

And verified that Jetty is listening at the port 8080:

# netstat -an | grep -w LISTEN

I think the commands on Debian Linux would be similar...

Alexander Farber
Alexander Farber
June 28, 2016 10:34 AM

What Alexander Farber suggest is basically correct and usable but I'd like to point to my little project which signals systemd about the life-cycle of Jetty.

In this project I'm trying to provide the best possible way to interface to systemd. The "simple" service type may not be the best in some situations because the service manager will consider the unit started immediately after the main service process has been forked off. (from systemd docs)

If there are dependent services, they may start sending requests to jetty before it's ready to receive them.

Also this means systemctl start command lines for simple services will report success even if the service's binary cannot be invoked successfully

meaning that if for some reason jetty couldn't start because of its configuration, it would anyway report a healthy state to systemd.

Additionally, in the provided example, I'm also trying to reproduce some useful functionality which is usually found in

August 14, 2019 18:46 PM

Related Questions

Can't find jetty config file on Fedora 28

Updated August 10, 2018 19:00 PM

NGINX wont start: localtion directive is not allowed

Updated January 21, 2016 09:00 AM