Hello My dear fellow Java Developer friends, Today I want to share with you one of the problem that I faced, and how I solved it. I was assigned to look for a better way to stop a Jetty server. We were stopping jetty by hitting ctrl + C or killing the process from the task manager. I have been searching the web for the solution : How to stop it from command prompt with no luck. Finally with one of our fellow blogger's post (read it here ), where he explained how Jetty can be started and stopped through an ant script, I was able to find a way to stop it using command prompt.
In order to start Jetty (which we all know) people usually use the following command:
java -jar start.jar (assuming you are dealing with Jetty7 eclipse version) However, if you want to be able to stop the jetty server from command prompt, you have to pass two extra jvm properties while starting, such as:
java -DSTOP.PORT=8079 -DSTOP.KEY=secret -jar start.jar
In order to stop Jetty :
java -DSTOP.PORT=8079 -DSTOP.KEY=secret -jar start.jar - –stop (Given the fact that you have used same jvm argument while starting that jetty server)
I hope those of you who are searching the way to stop jetty from command prompt, this post will save you some time.
If I'm not mistaking, the stop command should contain two dashes (--stop)...
ReplyDeleteYou are absolutely right, probably, due to the smart editing feature, the two small dash got converted to one bigger dash. Thanks a lot for pointing that out. I will correct it right away.
ReplyDeleteif you are using ubuntu you can actually stop and start it the same way as apache web server
ReplyDelete:$ sudo /etc/init.d/jetty stop
will print something like:
* Stopping Jetty servlet engine (was reachable on http://sysdev-vt:8080/). jetty * Jetty servlet engine stopped. jetty [ OK ]
:$ sudo /etc/init.d/jetty start
to start the server.
Viktor