Jump to: navigation, search

Jetty/Starting/Installing Jetty-7.0.x

Warning2.png
This page is deprecated
We are splitting it up into different pages. Once all the information here is available elsewhere, the page will be wiped



Introduction

The following provides detailed instructions for downloading and installing the latest version of Jetty 7. If you just want to get up and running, see the Quick Start Guide.

Prerequisites

Hardware

  • ~7 MB of disk space for Jetty source
  • ~7 MB for Jetty 7 binaries

Operating System

  • Any operating system that supports J2SE 1.5 or greater.

Environment

Downloading and Installing the Jetty Core Components Binary

Download the Binary

The Jetty core component binaries can be found on the Jetty downloads page.

Unpack the Binary

Unzip the binary; it will be extracted into a directory called jetty-distribution-VERSION. The rest of the instructions in this wiki will refer to this location as $JETTY_HOME.

Inspect the Distribution

Unzip the distribution you just downloaded. The top-level directory should look like:

about.html  contexts            etc   javadoc  LICENSE-APACHE-2.0.txt    logs      notice.html  resources  webapps
bin         contexts-available  lib   LICENSE-ECLIPSE-1.0.html  META-INF  README.txt   start.jar
about.html 
"About This Content" page from Eclipse
bin 
directory for shell scripts to help automate the building and running of Jetty
contexts 
hot deploy directory
contexts-available 
directory for additional example contexts
etc 
directory for Jetty configuration files
javadoc 
contains the javadoc; needs to be built first
lib 
contains all the JAR files necessary to run jetty-7
LICENSE-APACHE-2.0.TXT 
license file for Jetty (Jetty 7 is dual-licensed)
LICENSE-ECLIPSE-1.0.HTML 
license file for Jetty (Jetty 7 is dual-licensed)
logs 
directory for request logs
META-INF 
for packaging
notice.html 
licenses applicable to Jetty, as well as any exceptions
README.TXT 
contains useful getting started information
resources 
directory containing additional resources for configuration
start.jar 
JAR which invokes jetty-7 (see also Running Jetty)
webapps 
directory containing webapps which will be run under the default configuration of Jetty; contains demo webapps

Starting Jetty

To start Jetty, open the command shell, and:

cd $JETTY_HOME
java -jar start.jar

This starts Jetty running on port 8080.

Warning2.png
Jetty will not start if another process is using port 8080
The port number can be changed by editing the $JETTY_HOME/etc/jetty.xml file. For more details see Configuring Jetty. The rest of the instructions in this wiki will assume that you are using port 8080


Stopping Jetty

From the command shell where Jetty is running, type <ctrl-c>

Testing Jetty

When Jetty starts, it deploys a test web application on port 8080. To check if Jetty is running properly navigate to the test URL from a browser. For example:

http://localhost:8080/test
Note.png
Port and host defaults
If you started Jetty on another host, substitute that host name for localhost. If you used a different port number you will also need to change 8080 to the correct number. Unless otherwise noted, the rest of the instructions in this wiki will assume that you are using localhost and port 8080.


Configuring Jetty

To run Jetty with specific configuration files, do

java -jar start.jar etc/jetty.xml etc/jetty-someotherfile.xml etc/myconfiguration.xml

The part of the command following -jar start.jar specifies the names of configuration files. These files instruct Jetty which ports to listen on, which webapps to deploy, and generally configure all container-related customizable settings. You may have only one configuration file, or you may have many, depending on your needs. These configuration files may be any name you want.

Running Jetty with

 java -jar start.jar 

is exactly the same as

 java -jar start.jar etc/jetty.xml

The etc/jetty.xml file that is provided in the distribution includes many examples of alternative configuration settings that can be uncommented. For your convenience, this configuration instructs Jetty to deploy all webapps found in the webapps directory. Therefore, in order to deploy a new webapp, you need not do anything more than drop your war file or unpacked war file into the webapps directory.

In-depth configuration information can be found in Configuration Documentation.

Configuring Jetty Classpath on Startup

To control what files are available through the classpath, pass in options when starting Jetty, e.g.,

 java -jar start.jar OPTIONS=jetty,jsp,ssl

The default options are OPTIONS=default,*, which make available the modules for basic Jetty functionality, the $(jetty.home)/lib/ext directory, and the $(jetty.home)/resources directory.

A reference guide for the start.jar mechanism which controls the OPTIONS behavior can be found at Jetty/Reference/Customizing Startup.

Deploying Web Applications

The default installation of Jetty is configured to look for standard webapps in $JETTY_HOME/webapps. Webapps here will be discovered at startup, and do not support hot deployment.

For non-standard contexts, or if you need to support hot deployment, put XML configuration files to configure your contexts into $JETTY_HOME/contexts.

Idea.png
Root context
The easiest way to make your webapp the root context (/) is to name it "root.war".


Downloading Other Binaries

Other available binaries and packages for download are listed on Downloads.

Obtaining and Building from Source

You can also build a custom version of Jetty from the source code.

Check out the source code using SVN:

Follow the rest of the instructions on Building.