Restart an application in Eclipse - java

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?

You can restart running application by right clicking it in debug window and selecting "Terminate and relaunch".
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!

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

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

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.

Related

How to reuse the window (or close the current one) when hitting the Run button?

I'm using IntelliJ to run my app. Is there a way to relaunch the window or close the current one when hitting the run button?
This is because when I hit the run button it creates a new window every time. It gets a bit tedious/confusing to close the previous window that is running old code.
Go to the Run menu and select Edit configurations...
Select the configuration you've been using to run your project in the left panel. Either it's the Gradle yourProjectName:desktop [run] task, or it's an Application run configuration you've created yourself.
Uncheck the box that says "Allow parallel run".
The next time you try to run it when it's already running, it will warn you that it can only run it if it kills the old process. You can check a box in this dialog to do that automatically from now on.
I've never figured a way to toggle this behavior back to how it was, but I've rarely ever needed to compare two builds side-by-side.

How to make Eclipse jump back automatically to development prespective when app that was debugged finished?

How to make Eclipse jump back automatically to development prespective when app that was debugged finished executing? (like Visual Studio does)
I don't think standard eclipse platform ships with this feature/option.
what you could do is
click the right perspective button MANUALLY ,
define a short-cut for openning your 'development perspective' and press that key combination MANUALLY. this could be done in preference->keys
press ctrl-F8 (default bound) and select the right perspective
MANUALLY.
write your own plugin to switch perspective. of course,"MANUALLY"
too.

How to run arbitrary server software from Eclipse?

I am developing a Flex-based game, and struggling with SmartFox Server.
Anyway, it's a java-based server for Flash platform games, and it's kind of clunky to develop with on Windows. So, I want to be able to start it (and stop it) via Eclipse rather than the current batch file nastiness they provide.
The problem is I've never done that with a non-standard server that didn't just have a server adaptor in Eclipse.
I know it should be pretty simple, but how do I do it? It's really just a matter of calling a command line executable with some arguments, or even just running it as a Java application without its executable shell. Killing it would just be a matter of killing the process in Eclipse.
Also of note is that I want to make sure I have the shell output in Eclipse for debugging purposes.
I would think you could run it as an "External Tool" from Eclipse (the little green arrow with the toolbox). Click on the menu arrow to the right of that icon and select the "Configure External Tools" option.
You can then right click on the "Program" tree-node (on the Left hand side) and select "New" to create a new configuration. You will need to fill in the values similar to what you would do if you were running the server on the command line.
Give your configuration a meaningful name, like "SmartFox" or something.
Location is the command that is run (might point to java in your case).
To get the console setup, click on the "Common" tab and the "Allocate Console" checkbox should already be checked.
Once you are done, press the "Apply" or "Run" button.
You can then start the server by selecting it from the "External Tools" list (same icon as earlier) and you can stop it using the red stop icon on the console (should work).
Optional... the other tabs of the configuration dialog may be useful. You might want to have the build tab not do a build before launch, depending on how you have things set up.
What this wont give you (necessarily) is the tight integration between the server and Eclipse. You may have to do additional configuration or just deploy your code to the server as necessary.
Hopefully I am not way off base of what you were looking for.
Good luck.

Is it possible to start/stop Tomcat with keyboard shortcuts in Eclipse?

I'm trying to work in Eclipse as much as possible without a mouse. I cannot find a key binding for starting and stopping servers quickly in Eclipse WTP (Web Tools Platform).
One way to start a server is to switch to the package explorer (Alt+Cmd+Q P), select the project (up/down arrows) and then the "debug on server"-key binding (Shift+Alt+D R on the Mac). But this requires way too many steps.
I found a method that reduces starting a server down to two keystrokes (after some easy initial setup).
the tl;dr:
f11, enter.
you will likely need to do some setup to get this working:
Be sure you have a run/debug configuration defined for tomcat.
Click the run menu at the top of the window
Click Debug configurations...
Choose Apache Tomcat from the menu on the left
If there's not already a server defined there, click "new launch configuration" (top left) and choose the correct server from the select menu on the right pane (you must already have a tomcat server defined in your servers view)
save all that, go back to a file in your project and press f11 (First required keystroke).
if you get an error message that says something "could not find any code that could be executed on a server", then you either messed up the first step, or possibly your server is already running.
a dialog will pop up, the top choice being "Run on Server". Press enter (this is the 2nd required keystroke)
If this is your first time, you'll see another dialog after this which asks you to choose a server. Choose the server you want to run it on (you probably only have one), and check "always use this server when running this project" and you'll bypass this window in the future.
tip: you'll quickly notice that as a bonus, it will open up a web browser pointed at your server. you can change which browser it uses in windows->preferences->general->web browser.
and then there you have it. two keystrokes to start your server - f11, enter.
stopping it is another story. i haven't found a good way other than clicking the stop icon in severs or console. if you do, let me know...
While I don't perform the same steps as you to run my projects, I have created custom key-bindings to navigate around the eclipse environment. If you go to Eclipse Preferences > General > Keys, you will be able to map the majority of tasks to key-bindings that make the most sense to you.
One process you could perhaps follow is this:
Open package explorer via shortcut
Perform a 'Collapse All' on the tree (reduce vertical navigation in step 3)
Up/Down to your project
Run shift-alt-D, R to Debug on your server
If you have 'Link with Editor' turned on, when you go to edit a file again your tree will expand based on the context of your work.
CTRL+ALT+R to restart
CTL+ALT+S to stop
If u look in Help > Key assist (Ctrl+shift+L), You can see a shortcut named Tomcat start,stop.
The shortcut is Ctrl+Alt+T by default.

How do I restart the Google App Engine Java Server in Eclipse?

OK, maybe I'm dumb/blind, but in the docs it says "rebuild and restart the server." But I don't see a button to do this anywhere. Or from any contextual menu. And I can't find anything in their docs explaining how to do it. If I just try to start the app again, it gets angry because I already have App Engine running on the needed port.
Only solution I've found is to restart Eclipse... any other ideas? A screenshot of a button would help if possible. :)
In eclipse, there is a view that contains your Console. If you click on that, you will see the STDOUT and STDERR output of your running application. In the upper right, there should be a red box that will terminate the currently running program.
I have a different and possibly more productive solution for you. Like with most web development environments you probably want to change your source code and have Google Appengine server reload the new code for you.
You need some version of the traditional "touch" unix command (if you work on windows you can download a version from here).
Then go to you project properties, Builders and add a new build step as a "Program". Under "Location" enter the path to your "touch" command ("D:\bin\UnxUtils\usr\local\wbin\touch.exe" for example - on Posix systems just "touch" should be enough since it's already in your PATH) and in "Arguments" put something like "${project_loc}/war/WEB-INF/appengine-web.xml".
Also go to the "Build Options" tab and check "During auto builds".
"touch" will update the timestamp in you appengine-web.xml. When the App Engine server detects changes to you appengine-web.xml it will reload the app automatically. The load process is very fast so it can be done whenever you change any file in your project (which normally triggers the auto-build in Eclipse) - you can tweak the builder to only run when you change certain types of files.
I might add that the "little red box" is not always visible. It drove me crazy reading that same instruction but not seeing the terminate button until I discovered that the Console windows has "layers" that you can select from using the drop-down button on the far right of the controls for the Console view. You just need to go "back" to the console screen that says the server is running and you will see the little red terminate button.
The previous answer wasn't cutting the cheese for me. Upon first starting App Engine, the red square would be available above the text entry area. If I then clicked the run button again, then red square would go away and the console for the previous launch would be replaced by the console for the new launch. To manually stop the App Engine server, you can kill it from the terminal:
http://geekbrigade.wordpress.com/2009/02/26/how-to-find-and-kill-a-process-that-is-using-a-particular-port-in-ubuntu/
In short, "sudo netstat -lpn |grep :8888" and kill the service by process ID.
Strangely, adding Google Web Toolkit to the project made my App Engine launch show up in the Development Mode pane, where it could be easily be killed or restarted.
Just Click on Debug perspective (should be on upper right panel), select the instance of web application on Debug panel (if you don't show it, you could enable by menu Window->show view->Debug) and click on red box of view menu.
The best I've found is to setup the keyboard shortcuts for the console's terminate button, and the run/debug start/restart command. By default, you can enable Command-F2 to terminate, and Command-F11 to restart, its fairly painless. Make sure to enable the full debug menu group (click on main toolbar -> customize, etc)
If you include the gwt SDK in your project, the gwt development mode box contains a reload server button that will work just fine.

Categories

Resources