Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restart an application in Eclipse

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?

like image 935
ᴇʟᴇvᴀтᴇ Avatar asked Sep 17 '12 13:09

ᴇʟᴇvᴀтᴇ


3 Answers

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

like image 174
hfs Avatar answered Sep 22 '22 23:09

hfs


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!

like image 20
Ruuhkis Avatar answered Sep 20 '22 23:09

Ruuhkis


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

like image 26
Boon Avatar answered Sep 19 '22 23:09

Boon