开发者

Restarting an app in Eclipse

Is there any way to restart a program in Eclipse? (preferably 1-click)

I really wish the console view had something like a restart button that would kill the app and restart it with the latest changes.

This always takes me at least three clicks. I click the down arrow next to the green circle with开发者_如何学运维 white triangle (play button) to open the dropdown menu, then I click to choose the Java main that I want to run, and then to stop I click the red square terminate button in the console view. Is there any easier way to do this that requires fewer clicks?


In Eclipse 4.1 open: windows->Preferences->keys

in the filter text type: terminate and relaunch

In the binding add your binding (i use shift-F5)

For "when" select "In Windows"

This will do it in single shorcut for you.


Or install relaunch plugin:

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

which will enable you to restart anywhere


If you use "build automatically", there is a good chance that your changes are applied on the running program, on the fly. As such, most changes will be effective directly without a need to restart.

If there is a structural difference and Eclipse can't inject the new code (for example if you change anonymous classes, or inheritance patterns), then you will be prompted with a dialog inviting you to restart the application in one click:

Restarting an app in Eclipse

Exceptions are when you change the value of a static variable (or of the initialization of a class that won't be executed again until you restart the application). In this case indeed, you will need to restart explicitly with another method.


the console view has a terminate button (a red square) which stops the execution. then another click on the Run button (the green circle with triangle) begins execution again.
thats what i do - 2 clicks :)


If you're using Eclipse with Spring you could download the "Spring Tools X" plugin.
This will automatically add a start and relaunch button to the top bar menu.

Restarting an app in Eclipse

It should be available on any perspective.


I haven't found an elegant solution for this problem, but if your program is short running and you can live with a few instances here and there, you can just use the run command. Its default shortcut is Ctrl+F11. Every time you press this, your application will restart. BUT! If you press this while your application is still running, another instance will be run because the "old" instance won't be automatically terminated.

There are ways to really terminate your application using shortcut keys, but that requires setting breakpoints and then using the "terminate" command, and that isn't very elegant.


When developing my own network application, I have added a code to check if the older instance is running, and if so, then send an agreed command over network socket for graceful shutdown. While this approach may not be the best as universal solution, it allows clean shutdown of the previous instance, rather than just killing it.


Easy way without plugin, every Eclipse !

Click the project from of this icon at this time hold the shift Button, Project will restart (Terminate and relaunch) with server port also.

Restarting an app in Eclipse

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜