How to create default debug and run configuration in Eclipse? - eclipse

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?

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

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.

Related

Why is "Run configurations" invisible in my perspective?

Namely, I am working on a "New project wizard" plugin. When new project is created I open my perspective to display the project there. It is displayed as expected, but I can not run it since I can not see "Run configurations" menu item under my "Run" menu. I've been looking for a way to get this menu item back with no success. Now, I got curious why is it invisible. Someone knows it already?
Use Window > Customize Perspective.
Look at the Command Groups Availability and select Launch.
You may also want Launch on Tool Bar Visibility.

Is there a keyboard shortcut for stopping the current console in Eclipse?

I'm developping a Java application with a class containing main. I can start the application using Ctrl+Alt+X J subsequently the application can be re-run by hitting Alt+R T Enter to choose the menu option for the first item in the Run history.
But to stop the application, I have to click on the small red square in the console view. This is annoying, because it forces me to use the mouse, type Alt+R T Enter then re-focus the editor using the mouse again.
Eclipse being so configurable, there must be a keyboard shortcut to stop the application run in the current console I haven't found. There are an entry in Window > Preferences > Keys called Terminate and Terminate and Relaunch but no matter what binding I assign or what when conditions I set and no matter if I use the Debug perspective or not, they don't seem to fire.
Please help an Eclipse newbie avoiding the mouse :)
Go to Preferences -> General -> Keys
Find "Terminate" Set your binding to whatever you want.
Then change "When" from "Debugging" to "Editing Java Source".

In Eclipse, can I have multiple Console views at once, each showing a different Console?

I'm working on some applications that, in debug mode, log to the console. I'd like to run and debug them from inside of Eclipse, and view the console for each one simultaneously. However, I have a single Console tab that shows a single Console output at a time. Is there a way I can split the consoles into multiple views so that I can have side-by-side console output?
Yes,
located near your console tab should be a button "Open Console".
If you click this button one of your options should be "New Console View".
You'll now have 2 console views.
One of your other buttons near your console tab is "Display Selected Console". When you choose this option you can select from any of your running applications.
Just select the tab, select which application you want it to watch, and repeat for the other tab.
You can then move your 2 console views to wherever you want independently of each other.
I'm using Eclipse Helios Release with build ID: 20100617-1415.
The best thing you can do is the following.
Window > New Window.
That will create another eclipse window like you currently have. Run the desired application, switch the console on the new window to display the desired console output with open console button on the console view.
A bit clunky but the only way to get multiple consoles at the same time. If your new windows doesn't have console open use
Window > Show View > Console
Goodluck
The post of Chase Henslee it's correct after click on 1, you must deactivate the second behavior with second step and at finish you can change the console with 3 step.

Shortcut for running Android applications and JUnit test separately in Eclipse

I'm always running an Android application and a JUnit tests (not Android JUnit Test) back and forth. I've used the Run toolbar button in Eclipse to switch between them, which is quite boring after several times. It is possible to assign a run configuration to a shortcut key in Eclipse? (or at least create a toolbar button that does that)
I believe the answers from this question could help.
The standard Run shortcut (Ctrl+F11) is context sensitive depending on which window has focus. Take advantage of this by using Run History to run your app from a code window. Then open the JUnit window and use Run History to run the tests. Now, you can press Ctrl+F11 from either place to run the desired project.
You can bind a keyboard shortcut to the JUnit window and use standard window navigation keys to get to a code window. These combined with Ctrl+F11 make for pragmatic key combination.

Running Eclipse projects on the Command Prompt

I have a console-based C project in Eclipse. Is there a button I can press to launch my application in a Command Prompt window?
You can run your application as an External Tool, and there's a toolbar item for that. Looks like a green circle with a white arrow, beside a red toolbox. I'm a Java developer so I don't really know the CDT, but at least in the JDT you can run any command line tool in this way. (If it's not in your toolbar, right-click the toolbar and choose Customize Perspective… then find the External Tools item under Launch, and add it.)
First, click the down-arrow beside the button and then choose External Tools Configurations…. In the dialog, select Program from the left side and then click the New button in the toolbar. You are basically creating a shortcut that will live in the toolbar. At this point you can fill out the command line details to run your application. There's a lot of goodies like setting up environment variables, requiring a build of your projects before launching, etc. When you're done, save it, and you can run it as often as you like by clicking the arrow-and-toolbox button. You can come back and edit it later too, make duplicates, etc.
If you're working with a team, or you just want to do a really nice job:
In the Common tab, under Save as, choose Shared File. This will create a file in your project to represent the tool shortcut that you're building. That means you can check it into your source tree, and others can use it too. These files are XML so you want to check them in as text, not binary.
Start your working directory with ${workspace_loc} so that anyone who checks out your project can run it without having to adjust the shortcut for their file system.
Not directly, but you could configure an Ant task to run it (if it doesn't require console input), or you can configure firing up a JVM under Run|External Tools.