For the sake of this example, it is assumed the user is running Jetty as a distribution. For information on how to run Jetty as an embedded web server, please refer to the official documentation.
Jetty can be downloaded from here and is available in both .zip and .gzip formats. Current versions of Jetty require Java 1.8 to be installed, which can be obtained from Oracle's website.
Extract the distribution to a directory of your choosing. In the following example, this directory will be referred to as $JETTY_HOME. To start Jetty, simply start the start.jar file in the distribution from the command line:
Performing this from the $JETTY_HOME directory will produce an output similar to this:
The server is running, but you will notice that if you point your browser to localhost:8080, you receive a 404 error.
In the output above there is a warning about running the server from the $JETTY_HOME directory. Jetty 9.1 introduced the concept of having a Jetty Home directory and a Jetty Base directory (or directories). The basic premise is that the Jetty Home directory is the standard of truth for all server files. It contains all of the files required to run the server and the defaults for all server extensions. The Jetty Base directory (or directories) are for managing your instance(s) of Jetty and contain all of the web applications, third party plug-ins and customizations for your server. For more information, please see the official documentation on Managing Jetty Base and Jetty Home.
The Jetty distribution comes with a base directory with several web applications already configured. This directory is aptly named demo-base:
Now if you point your browser to localhost:8080 you will see a Jetty welcome page along with several links to example web applications as well as links to the official Jetty documentation and user groups. NOTE: The web applications that come with the Jetty distribution are not designed to be secure or fully functional, they are only provided as examples. Using them in your production environments is not recommended.
Congratulations! You have installed and started a Jetty web server. For more instructions on how to configure your server, and for more advanced subjects, please refer to the Official Documentation.
This modified text is an extract of the original Stack Overflow Documentation created by following contributors and released under CC BY-SA 3.0