Getting Started

If you are new to Eclipse Jetty, read on to download, install, start and deploy web applications to Jetty.

Quick Setup

Jetty is distributed in an artifact that expands in a directory called $JETTY_HOME, which should not be modified.

Configuration for Jetty is typically done in a directory called $JETTY_BASE. There may be more than one $JETTY_BASE directories with different configurations.

Jetty supports the deployment of Jakarta EE {8,9,10,11} web applications, as well as the deployment of Jetty specific web applications, as discussed in this section.

For example, the following commands can be used to set up a $JETTY_BASE directory that supports deployment of Jakarta EE 11 *.war files and a clear-text HTTP connector:

$ export JETTY_HOME=/path/to/jetty-home
$ mkdir /path/to/jetty-base
$ cd /path/to/jetty-base
$ java -jar $JETTY_HOME/start.jar --add-modules=http,ee11-deploy

The last command creates a $JETTY_BASE/start.d/ directory and other directories that contain the configuration of the server, including the $JETTY_BASE/webapps/ directory, in which Jakarta EE 11 *.war files can be deployed.

To deploy Jetty’s demo web applications, run this command:

$ java -jar $JETTY_HOME/start.jar --add-module=demos

Now you can start the Jetty server with:

$ java -jar $JETTY_HOME/start.jar

Point your browser at http://localhost:8080 to see the demo web applications deployed in Jetty.

The Jetty server can be stopped with Ctrl+C in the terminal window.

The following sections will guide you in details about downloading, installing and starting Jetty, and deploying your web applications to Jetty.

Read the Jetty architecture section for more information about Jetty modules, $JETTY_HOME, $JETTY_BASE and how to customize and start Jetty.

Downloading Jetty

The Jetty distribution is a file of the form jetty-home-<version>.<ext>, available for download from https://jetty.org/download.html

The Jetty distribution is available in both zip and gzip formats; download the one most appropriate for your system, typically zip for Windows and gzip for other operating systems.

Installing Jetty

After the download, unpacking Jetty will extract the files into a directory called jetty-home-<version>, where <version> is the version of Jetty that you downloaded. For example, installing Jetty 12.1.0-SNAPSHOT will create a directory called jetty-home-12.1.0-SNAPSHOT.

It is important that only stable release versions are used in production environments. Versions that have been deprecated or are released as Milestones (M), Alpha, Beta or Release Candidates (RC) are not suitable for production as they may contain security flaws or incomplete/non-functioning feature sets.

Unpack Jetty file into a convenient location, such as /opt. The rest of the instructions in this documentation will refer to this location as $JETTY_HOME, or ${jetty.home}.

For Windows users, you should unpack Jetty to a path that does not contain spaces.

If you are new to Jetty, you should read the Jetty architecture section to become familiar with the terms used in this documentation. Otherwise, you can jump to the section on starting Jetty.

Starting Jetty

Jetty as a standalone server has no graphical user interface; configuring and running the server is done from the command line.

First, create a $JETTY_BASE directory.

$ JETTY_BASE=/path/to/jetty.base
$ mkdir $JETTY_BASE
$ cd $JETTY_BASE

You will typically start Jetty by executing $JETTY_HOME/start.jar from this directory. However, if you try to start Jetty from an empty $JETTY_BASE, it will complain that you haven’t enabled any modules:

$ java -jar $JETTY_HOME/start.jar
[Running Jetty] :{jetty-home=/home/ubuntu/.cache/antora/collector/jetty.project@jetty-12.1.x-0d7163d445b52d375d8067eaaebde058af22174f/documentation/jetty/target/jetty-home-12.1.0-SNAPSHOT, jetty-version=undefined}
ERROR : No enabled jetty modules found!
INFO  : ${jetty.home} = /path/to/jetty.home
INFO  : ${jetty.base} = /path/to/jetty.home-base
ERROR : Please create and/or configure a ${jetty.base} directory.

Usage: java -jar $JETTY_HOME/start.jar [options] [properties] [configs]
       java -jar $JETTY_HOME/start.jar --help  # for more information

Jetty uses a module system to configure and assemble the server; these modules are enabled and configured in $JETTY_BASE. Since the $JETTY_BASE directory you just created is empty, Jetty has no configuration it can use to assemble the server.

See the architecture section of this document for more information on the design of Jetty’s module system.

You can explore what modules are available with the --list-modules flag:

$ java -jar $JETTY_HOME/start.jar --list-modules=*

Now try to enable the http module.

If you want to enable support for protocols like secure HTTP/1.1 or HTTP/2 or HTTP/3, or want to configure Jetty behind a load balancer, read this section.
$ java -jar $JETTY_HOME/start.jar --add-modules=http
[Running Jetty] :{args=--add-modules=http, highlight=([a-z\-]+ *transitively enabled), jetty-home=/home/ubuntu/.cache/antora/collector/jetty.project@jetty-12.1.x-0d7163d445b52d375d8067eaaebde058af22174f/documentation/jetty/target/jetty-home-12.1.0-SNAPSHOT, jetty-version=undefined}
INFO  : mkdir ${jetty.base}/start.d
INFO  : scheduler       transitively enabled
INFO  : server          transitively enabled
INFO  : logging-jetty   transitively enabled
INFO  : http            initialized in ${jetty.base}/start.d/http.ini
INFO  : resources       transitively enabled
INFO  : http-config     transitively enabled
INFO  : threadpool      transitively enabled
INFO  : logging/slf4j   dynamic dependency of logging-jetty
INFO  : bytebufferpool  transitively enabled
INFO  : mkdir ${jetty.base}/resources
INFO  : copy ${jetty.home}/modules/logging/jetty/resources/jetty-logging.properties to ${jetty.base}/resources/jetty-logging.properties
INFO  : Base directory was modified

When Jetty enables the http module, it also automatically enables a number of transitive dependencies of the http module, such as the server module, the logging-jetty module, and so on.

You can now start Jetty:

$ java -jar $JETTY_HOME/start.jar
[Running Jetty] :{args=--module=http, highlight=(\{.*:8080}), jetty-home=/home/ubuntu/.cache/antora/collector/jetty.project@jetty-12.1.x-0d7163d445b52d375d8067eaaebde058af22174f/documentation/jetty/target/jetty-home-12.1.0-SNAPSHOT, jetty-version=undefined}
2025-08-14 06:08:30.192:INFO :oejs.Server:main: jetty-12.1.0-SNAPSHOT; built: 2025-08-13T09:27:41.888Z; git: 2623240f329f3ae3661718cf4a35df81908b88de; jvm 21.0.8+9-LTS
2025-08-14 06:08:30.223:INFO :oejs.AbstractConnector:main: Started oejs.ServerConnector@562ea618{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2025-08-14 06:08:30.238:INFO :oejs.Server:main: Started oejs.Server@610f7aa{STARTING}[12.1.0-SNAPSHOT,sto=0] @1035ms

Jetty is listening on port 8080 for clear-text HTTP/1.1 connections. But since it has no web applications deployed, it will just reply with 404 Not Found to every request.

Before you deploy your first web application, take a moment to see what happened to the $JETTY_BASE directory once you enabled the http module:

$JETTY_BASE
├── resources
│   └── jetty-logging.properties (1)
└── start.d                      (2)
    ├── bytebufferpool.ini
    ├── http-config.ini
    ├── http.ini                 (3)
    ├── scheduler.ini
    ├── server.ini
    └── threadpool.ini
1 The resources/jetty-logging.properties file configures the server’s logging level; this file was auto-generated when the jetty-logging module was activated as a transitive dependency of the http module.
2 The start.d/ directory contains the *.ini configuration files for any modules you have enabled, either explicitly or transitively.
3 The start.d/http.ini file is the http module configuration file, where you can specify values for the http module properties.

Jetty generates *.ini configuration files in start.d/ also for modules enabled as transitive dependencies that have an [ini-template] directive.

In the http.ini file you can find the following (among other contents):

http.ini
--module=http (1)
# jetty.http.port=8080 (2)
...
1 This line enables the http module and should not be modified.
2 This commented line specifies the default value for the jetty.http.port property, which is the network port that Jetty uses to listen for clear-text HTTP connections.

Try changing the default port. Open http.ini, uncomment the line containing jetty.http.port=, and change its value to 9999:

http.ini
--module=http
jetty.http.port=9999
...

If you restart Jetty, it will use this new value:

$ java -jar $JETTY_HOME/start.jar
[Running Jetty] :{args=--module=http jetty.http.port=9999, highlight=(\{.*:9999}), jetty-home=/home/ubuntu/.cache/antora/collector/jetty.project@jetty-12.1.x-0d7163d445b52d375d8067eaaebde058af22174f/documentation/jetty/target/jetty-home-12.1.0-SNAPSHOT, jetty-version=undefined}
2025-08-14 06:08:31.651:INFO :oejs.Server:main: jetty-12.1.0-SNAPSHOT; built: 2025-08-13T09:27:41.888Z; git: 2623240f329f3ae3661718cf4a35df81908b88de; jvm 21.0.8+9-LTS
2025-08-14 06:08:31.677:INFO :oejs.AbstractConnector:main: Started oejs.ServerConnector@3a7054cb{HTTP/1.1, (http/1.1)}{0.0.0.0:9999}
2025-08-14 06:08:31.689:INFO :oejs.Server:main: Started oejs.Server@21b2e768{STARTING}[12.1.0-SNAPSHOT,sto=0] @915ms

You can also specify the value of a module property when you start up Jetty. A property value specified on the command-line in this way will override the value configured in a module’s *.ini file.

$ java -jar $JETTY_HOME/start.jar jetty.http.port=8080
[Running Jetty] :{args=--module=http jetty.http.port=8080, highlight=(\{.*:8080}), jetty-home=/home/ubuntu/.cache/antora/collector/jetty.project@jetty-12.1.x-0d7163d445b52d375d8067eaaebde058af22174f/documentation/jetty/target/jetty-home-12.1.0-SNAPSHOT, jetty-version=undefined}
2025-08-14 06:08:33.082:INFO :oejs.Server:main: jetty-12.1.0-SNAPSHOT; built: 2025-08-13T09:27:41.888Z; git: 2623240f329f3ae3661718cf4a35df81908b88de; jvm 21.0.8+9-LTS
2025-08-14 06:08:33.108:INFO :oejs.AbstractConnector:main: Started oejs.ServerConnector@63fa3de9{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2025-08-14 06:08:33.119:INFO :oejs.Server:main: Started oejs.Server@21b2e768{STARTING}[12.1.0-SNAPSHOT,sto=0] @905ms

For more detailed information about the Jetty start mechanism, you can read the Jetty start mechanism section.

Deploying Web Applications

Deployments of web applications in Jetty is detailed in this section.

Each web application is deployed to a specific environment, such as the old Java EE 8, or Jakarta EE 11, or Jetty specific environments.

Jetty supports simultaneous deployment of web applications each to a possibly different environment, for example an old Java EE 8 web application alongside a new Jakarta EE 11 web application.

In the following sections you can find simple examples of deployments of Jakarta EE 11 web applications.

Deploying *.war Files

A Jakarta EE 11 web application is packaged in either a *.war file or in a directory with the structure of a *.war file.

Recall that the structure of a *.war file is as follows:

mywebapp.war
├── index.html (1)
└── WEB-INF (2)
    ├── classes/ (3)
    ├── lib/ (4)
    └── web.xml (5)
1 Publicly accessible resources such as *.html, *.jsp, *.css, *.js files, etc. are placed in *.war or in sub-directories of the *.war.
2 WEB-INF is a special directory used to store anything related to the web application that must not be publicly accessible, but may be accessed by other resources.
3 WEB-INF/classes stores the web application’s compiled *.class files
4 WEB-INF/lib stores the web application’s *.jar files
5 WEB-INF/web.xml is the web application deployment descriptor, which defines the components and the configuration of your web application.

To deploy a Jakarta EE 11 web application, you need to enable the ee11-deploy module.

The following examples assume you are deploying a Jakarta EE 11 web application; for other versions of Jakarta EE, or for Jetty web applications, make sure to activate the corresponding deploy module.

Refer to the section about deployment for further information about how to deploy to different environments.

$ java -jar $JETTY_HOME/start.jar --add-modules=ee11-deploy
[Running Jetty] :{args=--add-modules=ee11-deploy, jetty-home=/home/ubuntu/.cache/antora/collector/jetty.project@jetty-12.1.x-0d7163d445b52d375d8067eaaebde058af22174f/documentation/jetty/target/jetty-home-12.1.0-SNAPSHOT, jetty-version=undefined, setup-args=--add-modules=http}
INFO  : sessions        transitively enabled
INFO  : security        transitively enabled
INFO  : ee11-deploy     initialized in ${jetty.base}/start.d/ee11-deploy.ini
INFO  : deployment-scanner transitively enabled
INFO  : ee-webapp       transitively enabled
INFO  : deployer-standard transitively enabled
INFO  : ee11-webapp     transitively enabled
INFO  : ee11-servlet    transitively enabled
INFO  : ee11-security   transitively enabled
INFO  : mkdir ${jetty.base}/webapps
INFO  : mkdir ${jetty.base}/environments
INFO  : Base directory was modified

The ee11-deploy module creates $JETTY_BASE/webapps, which is the directory where Jetty looks for any *.war files or web application directories to deploy.

Activating one of Jetty’s ee{8,9,10,11}-deploy modules enables web application deployment for that specific environment. Whether these web applications are served via clear-text HTTP/1.1, or secure HTTP/1.1, or secure HTTP/2, or HTTP/3 (or even all of these protocols) depends on whether the correspondent Jetty protocol modules have been enabled. Refer to the section about protocols for further information.

Now you’re ready to copy a web application to the $JETTY_BASE/webapps directory. You can use one of the demos shipped with Jetty:

$ java -jar $JETTY_HOME/start.jar --add-modules=ee11-demo-simple

The $JETTY_BASE directory is now:

$JETTY_BASE
├── resources
│   └── jetty-logging.properties
├── start.d
│   ├── ...
│   ├── ee11-deploy.ini
│   ├── ee11-demo-simple.ini
│   └── http.ini
└── webapps
    └── ee11-demo-simple.war

Now start Jetty:

$ java -jar $JETTY_HOME/start.jar
[Running Jetty] :{highlight=WebAppContext, jetty-home=/home/ubuntu/.cache/antora/collector/jetty.project@jetty-12.1.x-0d7163d445b52d375d8067eaaebde058af22174f/documentation/jetty/target/jetty-home-12.1.0-SNAPSHOT, jetty-version=undefined, setup-args=--add-modules=http,deploy,ee11-demo-simple}
ERROR : No enabled jetty modules found!
INFO  : ${jetty.home} = /path/to/jetty.home
INFO  : ${jetty.base} = /path/to/jetty.home-base
ERROR : Please create and/or configure a ${jetty.base} directory.

Usage: java -jar $JETTY_HOME/start.jar [options] [properties] [configs]
       java -jar $JETTY_HOME/start.jar --help  # for more information

Note the highlighted line that logs the deployment of ee11-demo-simple.war.

Now you can access the web application by pointing your browser to http://localhost:8080/ee11-demo-simple.

Advanced Deployment

If you want to customize the deployment of your web application — for example, by specifying a contextPath different from the file/directory name, or by specifying JNDI entries, or by specifying virtual hosts — read this section.