Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 861
D. Wroblewski Avatar asked Dec 17 '09 13:12

D. Wroblewski


3 Answers

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:

  1. 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)
  2. 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.
  3. a dialog will pop up, the top choice being "Run on Server". Press enter (this is the 2nd required keystroke)

  4. 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...

like image 120
Keith Avatar answered Oct 19 '22 10:10

Keith


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:

  1. Open package explorer via shortcut
  2. Perform a 'Collapse All' on the tree (reduce vertical navigation in step 3)
  3. Up/Down to your project
  4. 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.

like image 44
rynmrtn Avatar answered Oct 19 '22 09:10

rynmrtn


CTRL+ALT+R to restart
CTL+ALT+S to stop

like image 24
Gopi Kancharla Avatar answered Oct 19 '22 08:10

Gopi Kancharla