How to create default debug and run configuration in Eclipse?

Eclipse

Eclipse Problem Overview


Whenever I hit Debug or Run in Eclipse, I get a dialog asking me what configuration I want to use.

How do I set a default configuration and bind a keyboard shortcut?

Eclipse Solutions


Solution 1 - Eclipse

Maybe this article from Eclipse One Tips will help you:

> How to run the last launched application > > The answer lies in a preference hidden on the Run/Debug page: > > - Go to Window > Preferences > Run/Debug > Launching. > - Select the option Always launch the previously launched application. It’s located at the bottom of the dialog. > > The preference should look something like this: > > Launch previously launched prefrences Now you’re free to press > F11, Ctrl+F11 or click the Run/Debug > icons on the toolbar with confidence, knowing it’s going to run what > you expect it to run. > > One question arises: How do you quickly run a class as a specific > application (eg. a JUnit test) if you can’t press F11 to > run it? You have some options available: > > - The fastest way is to use keyboard shortcuts. Eclipse allows you to launch classes using a keystroke, including JUnit tests, Java > applications, etc using Alt+Shift+X. > - Alternatively, right-click on the class and select Run As. The submenu will show available options for launching the class. > - Lastly, you could click the pulldown arrow on the run/debug icons in the toolbar and select Run As. The submenu once again shows > available options for launching the class.

Solution 2 - Eclipse

Eclipse plug-ins that add new project types may contribute 'Launch Configurations' to control how Eclipse executes the application. For example, J2EE based projects need to publish content and start the application server. Contrast this with simply starting a JVM for a regular Java application.

When you select a configuration, Eclipse records this for future use. You can access these by selecting the 'Run/Run Configurations' menu item or selecting 'Run Configurations' from the little drop down menu next to the run and debug toolbar buttons. You can also add new launch configurations through the Run/Debug Configurations dialog that opens. In this dialog, you should see one or more configurations that you previously launched. Selecting one reveals all the info Eclipse uses to launch your application. One tab called 'Common' contains options for controlling the your favorites menu. Checking the box next to Run or Debug will add this launch configuration to the top of its corresponding menu.

If you only have a single configuration in your menu then Eclipse will launch it when you click the associated button. If you have more than one then Eclipse launches (sometimes) the most recently used. I say sometimes because, occasionally, one launch configuration causes another to launch, which cause the last used configuration to be the second one when you would expect it to be the first one. Usually this happens to me when I launch an application, which needs to be built and the build launches a tool. When this happens, just select the correct launch configuration from the drop down menu.

You can bind a keystroke combination to the Run and Debug commands through the 'Windows/Preferences' menu item. Then select 'General/Keys' in the tree control on the left.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNikola SmiljanićView Question on Stackoverflow
Solution 1 - EclipsenandaView Answer on Stackoverflow
Solution 2 - EclipseFaronView Answer on Stackoverflow