0
votes

I have a Jetty 9 server embedded in my app and found that when I launch the program in eclipse and then stop it via the eclipse red button, Jetty stays running in the background.

I have to do a netstat to find which process owns the port and then do a taskkill.

Now do I configure jetty to die when the host app dies?

1

1 Answers

0
votes

The Server instance should be told to stop.

server.stop();

Jetty does not know about any host app, it runs on its own daemon thread.

You could also just use java.lang.System.exit(int) to close the JVM and all threads it has running.

Killing the JVM (via the Eclipse Red Button) should kill all threads on that JVM too. If it doesn't, you have discovered a bug in Eclipse.

But before you go there, you should know that Eclipse IDE itself has it's own Eclipse Jetty server running (used for a number of things internally, and also for serving the documentation / help page).

So just the fact that you see an Eclipse Jetty instance running is misleading, it could be the one that the Eclipse IDE itself is running for its own reasons.