Restart an application in Eclipse
Asked Answered
I

4

10

I'm developing a standalone server (not a war) using Eclipse Juno. I run it as a Java application from Eclipse. After I've made some code changes, I want to stop the currently running server and start it up again. I do this tens of times a day.

The way I do that at the moment is as follows: - Go to the "Debug" tab. - Select the server process. - Click on the stop process icon (red square). - Click on the green arrow to re-run the last run application. - Go back to the "Java" tab.

Is there a quicker way?

Ideally, I'd like a button or keyboard shortcut that would stop and restart the application in one click. If it doesn't already exist, can I extend Eclipse in some way? Where should I look for an example of something like this?

Imprecise answered 17/9, 2012 at 13:53 Comment(0)
G
15

You can restart running application by right clicking it in debug window and selecting "Terminate and relaunch".

enter image description here

And quickly switching beetween views with Ctrl+F8

Also if you've already terminated the application from console, you can simply hit ctrl + f11

If you really want you can also add custom shortcut for terminating and relaunching by Window -> Preferences -> General -> Keys -> Find "Terminate and Relaunch" and choose your favorite key combination!

Grof answered 17/9, 2012 at 13:56 Comment(7)
Thanks for the advice. I've mapped it to "Ctrl-R". It's not ideal having to select the process, but it's probably good enough. It will certainly save me time over my current method.Braynard
I think this is as far as you can get without creating plugin, if you feel this question has been answered please accept answer.Grof
Thanks. I'll definitely accept this answer, if no-one comes with an even more convenient one! An Eclipse Monkey script perhaps?Braynard
I also suggest you to write rage about this feature missing on ihateeclipse.com it will make you feel better for sure!Grof
Is it possible to do this in the Java perspective? As in, not in the Debug perspective?Samualsamuel
@Saad Rehman, did you find any way of having this keystroke work outside the debug perspective?Feeney
@ParhamDoustdar Na bro, it just so happened, that I wasn't doing work that required Eclipse any longerSamualsamuel
I
7

Eclipse Neon.1 added a way to terminate before relaunch by holding Shift while clicking on a launch history item.

You can also make that the default behaviour by enabling the option “Terminate and Relaunch while launching” in Preferences › Run/Debug › Launching.

https://www.eclipse.org/eclipse/news/4.6/platform.php#terminate-relaunch-history

Impasto answered 6/10, 2016 at 7:39 Comment(0)
S
3

I had the exact problem you had. I had a simple Java class with a main method that runs an embedded tomcat.

When I change any of my service classes, I wanted to terminate the current embedded tomcat and relaunch with one single keystroke.

I know, I could have just clicked and done the same with 2 mouse clicks... but... it pained me enough to learn a wee wee bit about Eclipse plugin and threw something together.

Hope this helps you too.

https://bitbucket.org/mantis78/relaunch-plugin/wiki/Home

Syllabi answered 27/12, 2012 at 14:3 Comment(0)
P
-1

Simply saying, You can't modify eclipse Like you wants to. But You can follow this procedure to minimize your effort 1. In Eclipse Project TAb-> Check Build Automatically. 2. And After Every Changes You are making Just Run The Project using Green button in eclipse.

Also you Can use CTRL+F11 to run project.

Phipps answered 17/9, 2012 at 14:7 Comment(4)
Yeah, I already have it build automatically on save. What I need is a way to stop the currently running application before starting it again.Braynard
yes but like this, If Eclipse needs to restart it will get restarted Automatically(Or Eclipse Will ask you if you want to restart). Hence Like this You just need to Save changes And Run App, Eclipse will take care of everything ElsePhipps
Ah, it's not the Eclipse application itself that I'm talking about, it's an application that I have run from Eclipse (using the big green arrow button). If I keep clicking on the green arrow or press Ctrl-F11 Eclipse will start multiple instances of my application. It doesn't shutdown the one that's running.Braynard
Sorry I clicked Add Comment before I finished writing it... What I was saying was: If I keep clicking on the green arrow or press Ctrl-F11 Eclipse will start multiple instances of my application. (You can see them all running if you go to the Debug view).Braynard

© 2022 - 2024 — McMap. All rights reserved.