Is there a keyboard shortcut for stopping the current console in Eclipse? - 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".

Related

Ecplise IDE: Is there a way to automatically switch back in perspectives? [duplicate]

Eclipse by default automatically switches to the Debug perspective when you hit a breakpoint.
However, it is annoying me that it doesn't automatically switch back to the previous perspective (say, Java) when terminating the process.
It just stays in the debug perspective even though there is nothing to debug because nothing is running.
To complete mark's answer, that option tells Eclipse when to switch to the associated perspective upon program suspension - meaning when a breakpoint is hit, it will switch to Debug perspective.
Switching back to another perspective after you're done debugging has to be:
manual (mouse click)
manual ("Switch Perspective" shortcut CTRL F8)
automatic: Debug Perspective Auto Closer, which supplements bug 46336. (initially reported by zim)
Debug Perspective Auto Closer
Automatically opens previous perspective when debugging ends.
Behaviors: (configurable: Preferences -> Debug Perspective Auto Closer)
[default] when all debug launches have terminated, changes to perspective active on first launch
when any debug launch has terminated, changes to perspective active on that launch
If you want to avoid it switching to Debug in the first place, you can choose "Never" as the option (introduced in Eclipse 3.2 at the time).
(You can find the given Preferences page in Run/Debug > Perspective)
If you want to switch back in the situation where the debugged program terminates normally (Not when you want to stop debugging it yourself), you may hope Eclipse figures out that your program terminates normally and switch to a "default" perspective at that time...
However, there is no notion of "default" perspective, so how would Eclipse knows which one to switch to ? (the "Preferences/Perspectives/Make default" is only for the "Open Perspective" dialog, but that may not be the same perspective than the one you actually want to switch back to after a debug)
Also, should Eclipse closes the Debug perspective or just changes to a different one ?
What if there is more than one program running -- when one terminates, you might still be interested in debugging the other one, or maybe not.
The point is, the decision about when to change perspective (and what perspective to change to) is not reasonable for the machine to make -- it requires a person knowing what he wants to do next.
Ctrl + F8, the default shortcut to change views, reduces the pain a bit.
I filed a bug for this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=327983
I do not think it's possible to have eclipse switch back automatically but you can do it with the click of a button in the top-right of your window
you would need to write eclipse plugin
here i found example how in plugin switch perspective
As of 2015, this very basix UI woe is not addressed in Eclipse: the official bug report is assigned (but not fixed).
Fortunately, Sven Ramuschkat and Dirk Eismann wrote a plugin for that: the Perspective Switcher Plugin for Eclipse / Flash Builder
the Plugin will now automatically switch back from a Debug perspective to the previous non-Debug perspective as soon as the Debug session is terminated
It works on Eclipse Luna (and above)
Installation
Download the zip file , uncompress and copy the jar file in your eclipse/plugins folder.
Once it's done, you will see a new Preference pane.
Everything is configured for Eclipse to switch back to Java perspective if you have a java or properties file opened when the debugging session ends.

How to remove "Debug Current Instruction Pointer"

I tried to use the debugger in Eclipse, but when I hit my
breakpoints, the Eclipse "Debug Current Instruction Pointer" is often
pointing at the wrong source line.I really want to remove "Debug Current Instruction Pointer". "Project -> Clean..." doesn't seem to help, nor does
restarting Eclipse, nor does rebooting.
The "Debug Current Instruction Pointer" is the position where you paused debugging last time. You can simply resolve it by following the below two steps
Go to the "Debug" preference/panel
Then click on the red square button to terminate the debugging you were executing last time or press Ctrl+F2 (Windows)
Now, just debug the program again. The execution will be starting from the "Toggle Breakpoint".
Note: You can delete the Toggle Breakpoint by double click on the line number and redefine the new according to your requirements by right click on targeted line number and select "Toggle BreakPoint" or press Ctrl+Shift+B (Windows)
Go to the debug view (as your current debug session is running) and complete or terminate current debugging session. this way you will get rid of "Debug Current Instruction Pointer"
What helped me was remove all breakpoints - right-click, RemoveAll.
sometimes breakpoints remain in eclipse list even after we remove them by clicking over them, to remove
Show Breakpoints view by navigating menu
Window>>Show View>>Other>> Select Debug>>Breakpoints
In Breakpoints view, uncheck unnecessary breakpoints
To prevent this pointer from ever being displayed in the first place, go to
Preferences -> General -> Editors -> Text Editors -> Annotations ->
select Debug Current Instruction Pointer -> uncheck "Vertical ruler"
box
"Debug Current Insturction Pointer" isn't something you would want to remove since it is not something that is set in any way, ist just a pointer to the current instruction where the debugger has paused your application. You can see that easily if you just step through your application and see how the "Debug Current Insturction Pointer" is moving along.
If you think it is pointing at the wrong source-line there are two reasons I can think of right now:
There are some "old" breakpoints left from earlier debug-sessions. You should see the breakpoint-marker and be able to remove it. If you want to get rid of all existing breakpoints just go to the breakpoints-view and remove them all using the double-X-icon.
The source-file shown in the debug-window doesn't match the class file that is currently running. This is most likely to happen in some imported libraries and not in your own project's code, but if it still does happen a clean/rebuild should take care of the problem.
You need to get out of the current debug session. Go to the debug console and end the current session by hitting the red square button.
This should remove all the debug current instruction pointers.
Check the arguments written in Run Configuration, because they can be wrong.
To reach Run Configuration, right click the project's main class -> Run As -> Run Configurations -> Java Application on menu -> Arguments. In the text Area write your arguments and try to debug again.

Eclipse does not confirm exit when hitting command + q

I generally close tabs while using Eclipse with command+w, however, sometimes hit command+q by mistake. Even though I have Eclipse set-up to warn me when exiting (Preferences -> General -> Start-up and Shutdown, "Confirm exit when closing last window"), this shortcut seems to bypass the warning, which is quite annoying.
Is there a solution to this same as the way Chrome presents a warning when hitting this shortcut? A hack in some plist file maybe? Google searches have not helped much.
OK, so having the same problem with Safari and doing a google search led me to this Apple discussions page. Basically following these steps (via #evenhuis) you can re-map the quit shortcut to any other menu function:
Go to System Preference > Keyboard.
Choose Keyboard Shortcuts
Click Application Shortcuts
Press the + button
Under Application choose Eclipse
For Menu Title input "Show All". (You could use some
other innocuous menu option here)
For Short Cut use ⌘Q

Eclipse on Mac OS X : Shortcuts are broken

I'm pretty new to Eclipse because I'm starting to learn Java Programming. I'm having problem with the editor.
I'm running Eclipse on an iMac with a German keyboard. The keyboard shortcut for "Redo" action is Cmd+Shift+Z.
When I use this shortcut, a tiny window in the right down corner pops up and asks if I want "Inspect" or "Redo"...
In the preferences, I have three different "Inspect", (just one was with a shortcut, but it was something like Cmd+Shift+I). Anyway, I erased it to be sure.
Afterwards I tried again, but the same little window asks me for Insect or Redo. Now I don't know what to do.
I'm having the same problem with Cmd+R ("Run" action). For "Run" there is another keyboard binding.
In Eclipse preferences, I could not find both commands that are on the same shortcuts. Or better I found them but they are separate.
Go to the Keyboard shortcuts preferences :
Eclipse > Preferences > General > Keys
and unbind or rebind whatever is giving you trouble.
In your case, go to Inspect and remove the binding for Cmd+Shift+Z.
In some cases, removing the binding for a key command will remove all bindings for it so after you do so, check out Redo and make sure it is still tied to the command.

How to create default debug and run configuration in 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.