Unable to debug using eclipse debugger - java

So there is a small java program to add two numbers.
There is one break-point.
I used Debug as -> Java Application.
But still, Step Into, Step Over, Resume, Suspend and Terminate buttons are disabled in my eclipse.
See below:
Debugger recognized the breakpoint at int b = 3 but still the buttons are disabled.
Everything was working fine yesterday.
What should be the cause?

Possibles solutions and cause here.
The commands got disabled, probably from previous customization, (check General -> Keys) but I wouldn't think this can be the only reason to be cause of this issue.
Hope this helps you out.

I have met the same issue and fixed it. The following are the possible solutions:
Make sure that your skip all break point option is disabled
Reset your debug perspective in perspective options.
Make sure to restart eclipse after doing above things

Related

JUnit Stopping at Breakpoints in Files I Didn't Write and Don't Have Permission to

I am running unit tests on java code using intelliJ and junit. The unit tests were working fine, and they still are . . . until I run in debug mode. Today, when I run in debug mode, all of a sudden, they start iterating through java files that are installed with java, I didn't write, and that I don't have permission for like the following:
This is part of the java code base that I don't have any control over and I didn't set any breakpoint here. Yet it pauses here and makes me click through it to get past it. I wouldn't care if this was only a couple of additional clicks to click through, but I have clicked like 50 times and it still keeps going through base java code that I have no control over and is not what is throwing any problem or issue.
I tried changing the settings for code coverage but that didn't seem to do anything. Is there any way to get junit to only stop at breakpoints that I, myself, specified? Any help here would be appreciated. I didn't see a similar question on Stack Overflow and the stuff on other sites is all about crafting the unit test itself.
So crazy coder (see above) was correct, but I thought I would add (after painfully trying every other alternative) that you have to go to: Run | View Breakpoints and then scroll all the way down on the left side panel (which you may not notice if you have tons of breakpoints like I did) and at the bottom there are breakpoints for Java exceptions. You need to click those OFF see below:

Eclipse Terminate context menu entry greyed out

Before asking - I have checked similar questions and was not able to achieve my goal so far. My trouble resulted from CTRL+F2 not working in Eclipse. Therefore I spent time looking for shortcut settings and tested solutions here
What is the short cut in eclipse to terminate debugging/running?
or here
Eclipse Terminate Keyboard Shortcut
yet none of this seems to work.
By now I have discovered the reason why, so here is the question:
Why is my context menu Run > Terminate greyed out, even though a Java application is launched?
The steps I am taking are:
1) ALT+R to open Run context menu
2) N to open Run Configurations
3) ALT+R to run my configuration
4) The application launches as expected
5) Now I switch back to Eclipse and press ALT+R again - Terminate is greyed out, while the application is running.
Why is that?
Note:
This is the reason for the terminate shortcut not working properly, because this context menu entry is annotated with the according shortcut, as long as it is greyed out nothing will ever happen.
I am also in the Debug perspective.
Pressing the red rectangled Stop UI element will still kill the application, as it should. All the while the context menu entry in Run remains greyed out. Why would these two even map to different things?
Thanks in advance for any kind of insight.
This is only enabled when you have selected the application in the Debug view.
I was able to achieve what I was looking for with help of #greg-449.
The setup is now as follows:
In Eclipse open Window > Preferences > General > Keys > Show View (Debug) set a shortcut to ALT+ SHIFT + F2 as suggested in the sources I linked. Set binding to In Windows.
Now after launching it is possible to press the newly set shortcut to open debug and after that the Terminate context menu will become available, even though there is apparently no way to call Terminate all which is what the UI element does.
In conclusion, it is complicated, but at least it works. Being forced to manage launches this way still seems absurd to me, however.

Most debugging options greyed out in Eclipse

I've ran into a nasty NullPointerException in my code, it's nothing too bad, I should be able to fix it quite easily with some breakpoints and "Step Into".
The only problem is, almost all of the debugging options are greyed out for me in Eclipse, I've used them before and they worked fine, but now when I need them the most, they're not working!
I looked on the internet and tried some things like running eclipse with -clean, restarting, opening debug perspective, making sure skip breakpoints were disabled.. None of which worked unfortunately.
I'm guessing it's just me missing something really obvious but any help fixing this would be appreciated.
Well, It says "terminated", so your program must have ended execution.
That's why all the buttons are greyed out.
The exit value is 1, which indicates abnormal end to an execution of a program (program aborted without reaching the end). Try placing breakpoints earlier in the code to find out where it stops executing.
Your application already terminated. The debugging options are only enabled, when an actual debug application is running.

Log message/error at design-time in IntelliJ Idea?

I have had a problem with a custom component I am writing. The issue seems to be a resource not loading properly (not sure why) at design-time.
To track it down I'd like to put in some debug-code that will execute at design-time, and give output in form of some messages.
Is there a log or something similar that can be written to at design-time?
Thanks
There's a really nice trick you can use to add debug statements in IntelliJ without actually changing the code. The answer is to use non-suspending breakpoints.
Add a breakpoint at the necessary point in the code, then right click on it. De-select "Suspend", and then put whatever you want in the "Log evaluated expression" - this will give you access to the fields of the instance.
Run your app in debug mode, and you'll get debugging info in the console without having to manually examine everything.

Why eclipse while debugging access areas that has no break points?

When we debug, breakpoints are set before attaching to the process(even before starting application) and even though there are times that debugger go to places that has not been set to access.
I've checked and not modified the breakpoints list before starting program.
Regards
In eclipse preferences there is Java -> Debug. Check if the option Suspend execution on uncaught exceptions is checked. If that option is checked, the debugger will suspend execution when such an exception is thrown.
My friend who has no SO has solved that issue. There were break points in library that was imported by debugged project.
Those breakpoints are not visible in main project.

Categories