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

5

11

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.

Antipathetic answered 17/12, 2009 at 13:51 Comment(0)
B
4

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

Brittneybrittni answered 21/11, 2011 at 19:4 Comment(1)
You also might want to disable the annoying browser popup: #5008481Selry
B
1

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.

Brickyard answered 17/12, 2009 at 14:30 Comment(1)
I described this method in the question and think that it requires so many steps that I rather use my mouse.Antipathetic
I
1

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

Indicative answered 28/8, 2013 at 21:39 Comment(1)
That only works when focus is on Servers tabBrade
P
0

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.

Puryear answered 3/10, 2014 at 15:12 Comment(1)
I don't see this here: Eclipse IDE for Enterprise Java and Web Developers (includes Incubating components) Version: 2024-03 (4.31.0)Brade
B
0

enter image description here

Single key to start, single key to stop

Compatibility

  • ✅ Linux
  • ❕ macOS (probably)
  • ❓ Windows (possibly can be adapted)

Steps

  • Terminal:
echo 'kill $(pgrep -f tomcat)' > ~/some-path/kill-tomcat.sh
  • Eclipse:
    • Window > Preferences >

      • Run/Debug > Launching > Launch Operation: Always launch the previously launched application
      • General > Keys >
        • Type filter text: last lau
        • Bind commands below to those keys:
          • Debug Last Launched: F11 (it's the default)
          • Run Last Launched: F9 (just a suggestion, you can keep Ctrl F11 if you like)
          • Run Last Launched External tool: F10 (new shortcut - the a-ha part)
      • Apply and Close
    • External Tools (the play icon with a toolbox, near Debug and Coverage) > External Tools Configurations >

      • Program (double-click) > New_configuration >
        • Name: kill-tomcat
        • Location: /home/your-user/some-path/kill-tomcat.sh
        • Run

Now you just press F9 (or Ctrl F11) to start, F11 to debug and F10 to stop. F10 will run kill-tomcat.sh as long as it's the most recently launched external tool.

Brade answered 20/6 at 19:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.