## How do I run Jetty on a specific port?

Jetty will listen on a default port for incoming HTTP requests. The default is port 8080. To change this default, you set the system property `jetty.port` on the Jetty run line, eg:

      java -Djetty.port=8999 -jar start.jar config.xml

To add additional ports on which Jetty listens for HTTP traffic when using Jetty as a standalone HTTP server (ie not as a web application server), you add lines such as the following to your startup class:

        HttpServer server;   /* Jetty HTTP server instance */
        .
        .
        .
        SocketListener listener = new SocketListener(); /* make a new listener */
        listener.setPort(8080);   /* set up the port number */
        server.addListener(listener); // get the server listening on that port

To add another HTTP listener port to Jetty as a web-app server, you use your jetty xml configuration file, eg:

      <Call name="addListener">
        <Arg>
          <New class="org.mortbay.http.SocketListener">
            <Set name="Port">9999</Set>
            <Set name="MinThreads">5</Set>
            <Set name="MaxThreads">100</Set>
            <Set name="MaxIdleTimeMs">30000</Set>
            <Set name="LowResourcePersistTimeMs">5000</Set>
            <Set name="PoolName">Listener</Set>
          </New>
        </Arg>
      </Call>

If you don't know the difference between using Jetty as a pure HTTP server and Jetty as a web-app server, or you want more information on configurable attributes of port listeners, you should read the Jetty tutorial.

JettyFaq