Intellij Debugging - Why is step in/step out greyed out? - java

This is what I see in my Intellij UI IDE
The correct breakpoint is being hit(line 128 - checkRunFlag() )
but the step over/step in buttons next to console in the bottom left part of the screen are greyed out. Does anyone know what is causing this/how I can re-enable those buttons?

In my case it was greyed out until i entered a input (i.e part of program before breakpoint). After i entered the input using Scanner class, i was able to access step into and other buttons.

change to your debug application

I'm still not sure what the cause of this issue was but what I did to fix the issue was call kill -9 with the process id of Intellij
Then I restarted Intellij and it's working fine now

you can click the "pause pragram" to see where the breakpoints stopped. then make sure it's your expect application.

Related

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.

Unable to debug using eclipse debugger

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

Why isn't my project going into debug mode?

Hi i'm new to java and when I press the debug button it is not going into debug mode.
After clicking on the drop down arrow next to the icon it says 1 new configuration and when that launches it just says in the console 'OK'. If I go on debug as it just says none applicable.
If I go on debug configurations I don't really understand what I'm supposed to go on to get it into debug mode as i guess it is something to do with the configuration?
If it helps I'm trying to write code for a project, not android or anything like that. Hope this is enough information, thanks.
Did you remember to add a breakpoint somewhere? If not, add a breakpoint! You can do that by double clicking one of the line numbers in your source code.
You may also want to check the toolbar to see if you accidentally checked the "skip all breakpoints" option.

Kill java thread in Intellij-IDEA debugger

I've found several posts with instructions of how to kill java thread with jdb http://www.rhcedan.com/2010/06/22/killing-a-java-thread/ or on SO. This works.
Now I want to kill thread with Intellij-IDEA debugger. Is it possible to do?
There is a little icon on the right side of the Debug view:
This will open 'Threads' tab and there you can right-click on some of them and select 'Interrupt' (and press F9 if you are sleeping on some breakpoint).
The accepted answer is now outdated (at least it is different for me in IntelliJ 2022.3.2). Just in case anyone (like me) stumbles upon it, there is a button at the right side of the debugger that allows you to show threads (it is disabled by default).
see image below:
Then you'll be able to select the thread you want to modify through the debugger by right clicking it.

Categories