My java spark web application using the embedded jetty web server uses port number 4567. Unfortunately this port number is blocked on my computer and don't wish to unblock it. If looked at the spark documentation but it doesn't contain how to change the port number of the embedded Jetty server to 8080.
Asked
Active
Viewed 1.2k times
9
-
http://sparkjava.com/documentation.html#port – LEQADA Aug 31 '16 at 23:34
-
This might be a dupe. Have you checked this question: http://stackoverflow.com/questions/24644114/change-jetty-default-port – Daniel Wisehart Aug 31 '16 at 23:34
-
Possible duplicate of [How do I change the spark.ui.port?](http://stackoverflow.com/questions/27388332/how-do-i-change-the-spark-ui-port) – Andrew Li Aug 31 '16 at 23:35
1 Answers
14
You can set the port number in your java spark web application using the function port()
. This has to be done before using routes and filters
official documentation link: http://sparkjava.com/documentation.html#port
Example
port(8080);
// Routes of your endpoint...

rotsendroid
- 128
- 1
- 1
- 6

Francesco Ventura
- 607
- 8
- 19