title: How to get the automatically defined port for a Spark Java Application?
body: <p>In the API documentation for Java Spark (not Apache spark), you can specify a port of 0 to have it automatically select a port. Great!</p>
  
  <p>However, I cannot figure out how to get that port after the server is started. I can see it in the logs:</p>
  
  <pre><code>15:41:12.459 [Thread-2] INFO  spark.webserver.JettySparkServer - &gt;&gt; Listening on 0.0.0.0:63134
  </code></pre>
  
  <p>But I need to be able to get to it programmatically, so that my integration tests are able to run reliably every time.</p>
  
  <p>So how do I get that port?</p>