Monday, September 2, 2019

Java - Run jar file on non default port

If you are running a jar file using command
java -jar filename.jar
Suppose it runs on port 8080. But you have already another service like Tomcat or Jenkins running on port 8080 so your jar file can not run on port 8080. Here is an option '-Dserver.port', Using the option you can choose the port on which your jar file should be run.
java -Dserver.port=8999 -jar filename.jar
Now your service will run on port 8999.

No comments:

Post a Comment