Jetty Logo
Version: 9.3.7.v20160115
Contact the core Jetty developers at

private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery

Chapter 24. Embedding

Table of Contents

Jetty Embedded HelloWorld
Embedding Jetty
Embedded Examples

Jetty Embedded HelloWorld

This section provides a tutorial that shows how you can quickly develop embedded code against the Jetty API.

Downloading the Jars

Jetty is decomposed into many jars and dependencies to achieve a minimal footprint by selecting the minimal set of jars. Typically it is best to use something like Maven to manage jars, however this tutorial uses an aggregate Jar that contains all of the Jetty classes in one Jar. You can manually download the aggregate jetty-all.jar using curl) or a browser.


The central maven repository has started to aggressively reject/deny access to the repository from the wget command line tool (due to abusive use of the tool by some groups). The administrators of the central maven repository have stated that the recommended command line download tool is now curl.

Use curl as follows:

> mkdir Demo
> cd Demo
> curl -o jetty-all-uber.jar

Writing a HelloWorld Example

The Embedding Jetty section contains many examples of writing against the Jetty API. This tutorial uses a simple HelloWorld handler with a main method to run the server. You can either download or create in an editor the file with the following content:

Compiling the HelloWord example

The following command compiles the HelloWorld class:

> mkdir classes
> javac -d classes -cp jetty-all-uber.jar

Running the Handler and Server

The following command runs the HelloWorld example:

> java -cp classes:jetty-all-uber.jar org.eclipse.jetty.embedded.HelloWorld

You can now point your browser at http://localhost:8080 to see your hello world page.

Next Steps

To learn more about Jetty, take these next steps:

See an error or something missing? Contribute to this documentation at Github!(Generated: 2016-03-17)