Follow each step to build an app from scratch, or skip to the end get the source for this article. You can also use almost any existing Maven webapp project.

Prerequisites

Basic Java knowledge, including an installed version of the JVM and Maven.

Basic Git knowledge, including an installed version of Git.

What is Jetty and Jetty Runner?

Jetty is a lightweight Java application server that offers a flexible array of options for how it can be launched. One popular option is using embedded Jetty the way that the Java quickstart does. Another good option is the Jetty Runner jar file. Each version of Jetty that is released includes a Jetty Runner jar. This jar can be run directly from the java command and can be passed a war file to load right on the command line. An example of this would be:

$ java -jar jetty-runner.jar application.war

Jetty Runner will then launch a Jetty instance with the given war deployed to it.

(you can pick any groupId or artifactId). You now have a complete Java web app in the helloworld directory.

Configure Maven to download Jetty Runner

Although not necessary for using Jetty Runner it’s a good idea to have your build tool download Jetty Runner for you since your application will need it to run. You could, of course, just download Jetty Runner and use it to launch your application without doing this. However having all of your dependencies defined in your build descriptor is important for application portability and repeat-ability of deployment. In this case we’re using Maven so we’ll use the dependency plugin to download the jar. Add the following plugin configuration to your pom.xml: