title: Change Jetty default port
body: <p>Jetty default port is 8080, but I want to change to default port to some other port (9999). </p>
  
  <p>I read a few tutorials and they said almost all of configuration information is by default maintained in file <code>jetty.xml</code>, this file is located under <code>$JETTY_HOME/etc/</code>. Then, change property <code>jetty.port</code> to 9999. However, when I opened up that file, I couldn't find jetty.port property inside the <code>jetty.xml</code>. I'm currently using Jetty-9.2.1 and the port is at 8080. </p>
  
  <p>I found jetty.port property under jetty-http.xml file. Even though I changed the port to 8090 in the jetty-http.xml file, jetty is still running at port 8080. </p>
  
  <p><strong>jetty.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"&gt;
  
  &lt;!-- =============================================================== --&gt;
  &lt;!-- Documentation of this file format can be found at:              --&gt;
  &lt;!-- http://wiki.eclipse.org/Jetty/Reference/jetty.xml_syntax        --&gt;
  &lt;!--                                                                 --&gt;
  &lt;!-- Additional configuration files are available in $JETTY_HOME/etc --&gt;
  &lt;!-- and can be mixed in. See start.ini file for the default         --&gt;
  &lt;!-- configuration files.                                            --&gt;
  &lt;!--                                                                 --&gt;
  &lt;!-- For a description of the configuration mechanism, see the       --&gt;
  &lt;!-- output of:                                                      --&gt;
  &lt;!--   java -jar start.jar -?                                        --&gt;
  &lt;!-- =============================================================== --&gt;
  
  &lt;!-- =============================================================== --&gt;
  &lt;!-- Configure a Jetty Server instance with an ID "Server"           --&gt;
  &lt;!-- Other configuration files may also configure the "Server"       --&gt;
  &lt;!-- ID, in which case they are adding configuration to the same     --&gt;
  &lt;!-- instance.  If other configuration have a different ID, they     --&gt;
  &lt;!-- will create and configure another instance of Jetty.            --&gt;
  &lt;!-- Consult the javadoc of o.e.j.server.Server for all              --&gt;
  &lt;!-- configuration that may be set here.                             --&gt;
  &lt;!-- =============================================================== --&gt;
  &lt;Configure id="Server" class="org.eclipse.jetty.server.Server"&gt;
  
      &lt;!-- =========================================================== --&gt;
      &lt;!-- Configure the Server Thread Pool.                           --&gt;
      &lt;!-- The server holds a common thread pool which is used by      --&gt;
      &lt;!-- default as the executor used by all connectors and servlet  --&gt;
      &lt;!-- dispatches.                                                 --&gt;
      &lt;!--                                                             --&gt;
      &lt;!-- Configuring a fixed thread pool is vital to controlling the --&gt;
      &lt;!-- maximal memory footprint of the server and is a key tuning  --&gt;
      &lt;!-- parameter for tuning.  In an application that rarely blocks --&gt;
      &lt;!-- then maximal threads may be close to the number of 5*CPUs.  --&gt;
      &lt;!-- In an application that frequently blocks, then maximal      --&gt;
      &lt;!-- threads should be set as high as possible given the memory  --&gt;
      &lt;!-- available.                                                  --&gt;
      &lt;!--                                                             --&gt;
      &lt;!-- Consult the javadoc of o.e.j.util.thread.QueuedThreadPool   --&gt;
      &lt;!-- for all configuration that may be set here.                 --&gt;
      &lt;!-- =========================================================== --&gt;
      &lt;!-- uncomment to change type of threadpool
      &lt;Arg name="threadpool"&gt;&lt;New id="threadpool" class="org.eclipse.jetty.util.thread.QueuedThreadPool"/&gt;&lt;/Arg&gt;
      --&gt;
      &lt;Get name="ThreadPool"&gt;
        &lt;Set name="minThreads" type="int"&gt;&lt;Property name="threads.min" default="10"/&gt;&lt;/Set&gt;
        &lt;Set name="maxThreads" type="int"&gt;&lt;Property name="threads.max" default="200"/&gt;&lt;/Set&gt;
        &lt;Set name="idleTimeout" type="int"&gt;&lt;Property name="threads.timeout" default="60000"/&gt;&lt;/Set&gt;
        &lt;Set name="detailedDump"&gt;false&lt;/Set&gt;
      &lt;/Get&gt;
  
      &lt;!-- =========================================================== --&gt;
      &lt;!-- Add shared Scheduler instance                               --&gt;
      &lt;!-- =========================================================== --&gt;
      &lt;Call name="addBean"&gt;
        &lt;Arg&gt;
          &lt;New class="org.eclipse.jetty.util.thread.ScheduledExecutorScheduler"/&gt;
        &lt;/Arg&gt;
      &lt;/Call&gt;
  
      &lt;!-- =========================================================== --&gt;
      &lt;!-- Http Configuration.                                         --&gt;
      &lt;!-- This is a common configuration instance used by all         --&gt;
      &lt;!-- connectors that can carry HTTP semantics (HTTP, HTTPS, SPDY)--&gt;
      &lt;!-- It configures the non wire protocol aspects of the HTTP     --&gt;
      &lt;!-- semantic.                                                   --&gt;
      &lt;!--                                                             --&gt;
      &lt;!-- This configuration is only defined here and is used by      --&gt;
      &lt;!-- reference from the jetty-http.xml, jetty-https.xml and      --&gt;
      &lt;!-- jetty-spdy.xml configuration files which instantiate the    --&gt;
      &lt;!-- connectors.                                                 --&gt;
      &lt;!--                                                             --&gt;
      &lt;!-- Consult the javadoc of o.e.j.server.HttpConfiguration       --&gt;
      &lt;!-- for all configuration that may be set here.                 --&gt;
      &lt;!-- =========================================================== --&gt;
      &lt;New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration"&gt;
        &lt;Set name="secureScheme"&gt;https&lt;/Set&gt;
        &lt;Set name="securePort"&gt;&lt;Property name="jetty.secure.port" default="8443" /&gt;&lt;/Set&gt;
        &lt;Set name="outputBufferSize"&gt;&lt;Property name="jetty.output.buffer.size" default="32768" /&gt;&lt;/Set&gt;
        &lt;Set name="requestHeaderSize"&gt;&lt;Property name="jetty.request.header.size" default="8192" /&gt;&lt;/Set&gt;
        &lt;Set name="responseHeaderSize"&gt;&lt;Property name="jetty.response.header.size" default="8192" /&gt;&lt;/Set&gt;
        &lt;Set name="sendServerVersion"&gt;&lt;Property name="jetty.send.server.version" default="true" /&gt;&lt;/Set&gt;
        &lt;Set name="sendDateHeader"&gt;&lt;Property name="jetty.send.date.header" default="false" /&gt;&lt;/Set&gt;
        &lt;Set name="headerCacheSize"&gt;512&lt;/Set&gt;
        &lt;!-- Uncomment to enable handling of X-Forwarded- style headers
        &lt;Call name="addCustomizer"&gt;
          &lt;Arg&gt;&lt;New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/&gt;&lt;/Arg&gt;
        &lt;/Call&gt;
        --&gt;
      &lt;/New&gt;
  
  
      &lt;!-- =========================================================== --&gt;
      &lt;!-- Set the default handler structure for the Server            --&gt;
      &lt;!-- A handler collection is used to pass received requests to   --&gt;
      &lt;!-- both the ContextHandlerCollection, which selects the next   --&gt;
      &lt;!-- handler by context path and virtual host, and the           --&gt;
      &lt;!-- DefaultHandler, which handles any requests not handled by   --&gt;
      &lt;!-- the context handlers.                                       --&gt;
      &lt;!-- Other handlers may be added to the "Handlers" collection,   --&gt;
      &lt;!-- for example the jetty-requestlog.xml file adds the          --&gt;
      &lt;!-- RequestLogHandler after the default handler                 --&gt;
      &lt;!-- =========================================================== --&gt;
      &lt;Set name="handler"&gt;
        &lt;New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection"&gt;
          &lt;Set name="handlers"&gt;
           &lt;Array type="org.eclipse.jetty.server.Handler"&gt;
             &lt;Item&gt;
               &lt;New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/&gt;
             &lt;/Item&gt;
             &lt;Item&gt;
               &lt;New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/&gt;
             &lt;/Item&gt;
           &lt;/Array&gt;
          &lt;/Set&gt;
        &lt;/New&gt;
      &lt;/Set&gt;
  
      &lt;!-- =========================================================== --&gt;
      &lt;!-- extra server options                                        --&gt;
      &lt;!-- =========================================================== --&gt;
      &lt;Set name="stopAtShutdown"&gt;true&lt;/Set&gt;
      &lt;Set name="stopTimeout"&gt;5000&lt;/Set&gt;
      &lt;Set name="dumpAfterStart"&gt;&lt;Property name="jetty.dump.start" default="false"/&gt;&lt;/Set&gt;
      &lt;Set name="dumpBeforeStop"&gt;&lt;Property name="jetty.dump.stop" default="false"/&gt;&lt;/Set&gt;
  
  &lt;/Configure&gt;
  </code></pre>
  
  <p><strong>jetty-http.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd"&gt;
  
  &lt;!-- ============================================================= --&gt;
  &lt;!-- Configure the Jetty Server instance with an ID "Server"       --&gt;
  &lt;!-- by adding a HTTP connector.                                   --&gt;
  &lt;!-- This configuration must be used in conjunction with jetty.xml --&gt;
  &lt;!-- ============================================================= --&gt;
  &lt;Configure id="Server" class="org.eclipse.jetty.server.Server"&gt;
  
    &lt;!-- =========================================================== --&gt;
    &lt;!-- Add a HTTP Connector.                                       --&gt;
    &lt;!-- Configure an o.e.j.server.ServerConnector with a single     --&gt;
    &lt;!-- HttpConnectionFactory instance using the common httpConfig  --&gt;
    &lt;!-- instance defined in jetty.xml                               --&gt;
    &lt;!--                                                             --&gt;
    &lt;!-- Consult the javadoc of o.e.j.server.ServerConnector and     --&gt;
    &lt;!-- o.e.j.server.HttpConnectionFactory for all configuration    --&gt;
    &lt;!-- that may be set here.                                       --&gt;
    &lt;!-- =========================================================== --&gt;
    &lt;Call name="addConnector"&gt;
      &lt;Arg&gt;
        &lt;New class="org.eclipse.jetty.server.ServerConnector"&gt;
          &lt;Arg name="server"&gt;&lt;Ref refid="Server" /&gt;&lt;/Arg&gt;
          &lt;Arg name="factories"&gt;
            &lt;Array type="org.eclipse.jetty.server.ConnectionFactory"&gt;
              &lt;Item&gt;
                &lt;New class="org.eclipse.jetty.server.HttpConnectionFactory"&gt;
                  &lt;Arg name="config"&gt;&lt;Ref refid="httpConfig" /&gt;&lt;/Arg&gt;
                &lt;/New&gt;
              &lt;/Item&gt;
            &lt;/Array&gt;
          &lt;/Arg&gt;
          &lt;Set name="host"&gt;&lt;Property name="jetty.host" /&gt;&lt;/Set&gt;
          &lt;Set name="port"&gt;&lt;Property name="jetty.port" default="8090" /&gt;&lt;/Set&gt;
          &lt;Set name="idleTimeout"&gt;&lt;Property name="http.timeout" default="30000"/&gt;&lt;/Set&gt;
          &lt;Set name="soLingerTime"&gt;&lt;Property name="http.soLingerTime" default="-1"/&gt;&lt;/Set&gt;
        &lt;/New&gt;
      &lt;/Arg&gt;
    &lt;/Call&gt;
  
  &lt;/Configure&gt;
  </code></pre>
  
  <p>I was also advised to use an integration test to configure Jetty to use other port. There's a <code>integration-tests.properties</code> file inside the project. Maybe a solution is to set jetty.port to 9999 inside this file? </p>
  
  <p><strong>integration-tests.properties:</strong></p>
  
  <pre><code>host = localhost
  port = 9999
  </code></pre>