Frank Meulenaar
Frank Meulenaar

Reputation: 1209

Eclipse shortcut to run a class

I have an Eclipse project where I often launch the same java class. I have added my run configuration to the favorites menu, but to launch it I still need to click on the run-drop-down menu and click the icon - is there any way to associate a shortcut to this? When I searched for it I got lost in all the plugins & other things which seemed to be not so simple.

edit: Let me clarify, I want something I can type the moment I start eclipse, regardless of what page I'm viewing, so no "run last" or "run current"; I want F12 to link to "launch foo.bar.MainClass".

Upvotes: 30

Views: 69664

Answers (13)

Olivier Juin
Olivier Juin

Reputation: 1

Just create an "External tool configuration" instead of a standard configuration for the class you want to run, and assign a shortcut key to "Run last launched external Tool".

Of course, there shall be no other external tool configuration.

Even if other java programs have been launched, or the current class contains a main() method, hitting the shortcut key will always run the same configured class.

Upvotes: 0

krishna prasad peram
krishna prasad peram

Reputation: 11

If you are someone like me who wants to create a shortcut to run a class/program in java directly, you can create your own preferable shortcut in ECLIPSE!

Follow these steps:

Window > Preferences > General > Keys

  1. Select run from command column
  2. Enter your own shortcut in Binding section
  3. Apply and close!!

WARNING: Make sure you don't create a shortcut which is already assigned for a different task!

Upvotes: 1

Joydeep Das
Joydeep Das

Reputation: 31

It is Ctrl+F11

Ctrl+Shift+X or Ctrl+Shift+J didn't worked for me!

Upvotes: 3

ilyas naghiyev
ilyas naghiyev

Reputation: 11

on Windows machine ctrl+Fn F11 --- running ctrl+Fn+Shift F11 --- debugging

Upvotes: 1

TuringGR
TuringGR

Reputation: 41

You can go Window -> Preferences -> General -> Key and bind anything you want!I hope it helps!

Upvotes: 4

Mayur Kharche
Mayur Kharche

Reputation: 717

I faced this problem in eclipse too. I have customized the configuration for me.

Windows -> preferances -> keys

Search for your configuration eg "Run Java Application" or just look for its icon.

Select it

and below in the binding field press keyboard keys which you want to add a shortcut for this configuration eg. ctrl + shift + T

and Apply

You are good to go use the same shortcut keys to whenever you need it.

Upvotes: 0

Verhagen
Verhagen

Reputation: 4034

  • Open the workspace preferences by the menu: Window > Preferences
  • Select from the tree: Run/Debug > Launching
  • Now the Launching preferences are seen.
  • At the bottom there is Launch Operation
  • Use the option Always launch the previously launched application

Upvotes: 31

xentaros
xentaros

Reputation: 11

If you've added these classes to your favorite run configurations (available from the run/debug toolbar buttons as "Organize Favorites..."), then the shortcut key combo is Alt+R,T,1 to run your first favorite, Alt+R,T,2 to run your second, etc. Alt+R,H,# works for debug configs.

Upvotes: 1

Dan Ortega
Dan Ortega

Reputation: 1899

Just use Ctrl + F11. (This is the standard keyboard shortcut to run the class you are working on)

I wish this is what you are looking for... buddy.

Upvotes: 33

Faboo03
Faboo03

Reputation: 43

I cannot this the answer here but : CTRL+SHIFT+T do apparently exactly what you want! :) Maybe it's because you code it by yourself by time...

Watch here: http://eclipse.dzone.com/news/effective-eclipse-shortcut-key for more.

Upvotes: 0

Jherico
Jherico

Reputation: 29240

You should put in a feature request in the eclipse bug tracker (or vote up an existing equivalent feature request) or code it yourself.

Upvotes: 3

ibrahimyilmaz
ibrahimyilmaz

Reputation: 18919

alt+shift+x+J Rocks

Upvotes: 6

tangens
tangens

Reputation: 39733

You can configure your launch behaviour so Ctrl-F11 will launch the last launched application again, regardless of your current editor selection.

Look at "Run/Debug" - "Launching" within the eclipse preferences.

Upvotes: 26

Related Questions