Jetty Run War Using only command line

Use the jetty runner.

 java -jar jetty-runner.jar my.war

With Maven, you can install by adding to your pom.xml:

<build>
    ...
    <plugins>
        ...
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals><goal>copy</goal></goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>org.mortbay.jetty</groupId>
                                <artifactId>jetty-runner</artifactId>
                                <version>7.5.4.v20111024</version>
                                <destFileName>jetty-runner.jar</destFileName>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Run:

mvn package

And use as:

java -jar target/dependency/jetty-runner.jar target/*.war

http://www.eclipse.org/jetty/documentation/current/runner.html

http://central.maven.org/maven2/org/eclipse/jetty/jetty-runner/

Leave a Comment