When I try to use the debugger (F7) in NetBeans, it does not seem to work properly for me. While normally it would move step by step through the program, my debugger instead opens a new tab called "scanner.java" the second time I press F7. If someone could help me with this issue, that'd be great!
According to the documentation (see all shortcuts here)
F7 is for stepping into
F8 is for stepping over
So, it is behaving correctly. When you step into some code the debugger moves into that calls stack.
If you want to "move step by step through the program" you need to press F8
Further readings
Oracle documentation: Running and Debugging Java Application Projects, Table 9-3 Debugging Step Commands and Icons
Related
it happens to me many times: I'm stepping with the debugger through my code, and ups! i made one step too far! Debugging, and made one step over too far
what now? restart the whole debugging session?
actually, there is a way to go ‘backwards’
The feature is called 'Drop to frame' right click on any line in stack, choose 'Drop to frame' and you go back to selected method beginning
https://help.eclipse.org/2021-03/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/views/debug/ref-droptoframe.htm
You can only jump to the start of the current function . Please keep that in mind.
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.
Sorry for the strange name of my question. I don't know how to look for this because I don't know how these things are called.
There's a features in Visual Studio at least where you can click on the left of the code and set a starting point which is a big red dot. Then you run the program and you can trace the steps by pressing f8 or f5 (different f's really) and you see the variable values on each step etc. I find it extremely useful because I can see where an error occurs and how the program behaves.
I have no idea what this is called and I want to ask is there such a thing in NetBeans IDE 8.0.2 or jGrasp or any java compiler?
Sorry if anything sounds stupid, I'm kind of a newbie.
Thank you all
Most IDEs have debugging functionality built in.
In Netbeans, you can easily add/remove a break point by simply clicking the line number on right side of the source editor (you can also do via the editor popup menu)
You start the debugger through F5 (ShiftF5 for debug the current file) or via the debug icon on the toolbar
You can use F8 to step over the command/method call, F7 to step into a method. You can resume running the program using F5 while the debugger is running.
See Debugger and Profiler and Using the Visual Debugger in NetBeans IDE for more details
Finding how to do this in your IDE is pretty easy, see the other answers.
What is a bit more difficult is debugging an external (and/or) remote Java program in your IDE. Here it is how to do that with Eclipse: http://www.ibm.com/developerworks/library/os-eclipse-javadebug/. I guess other IDEs are similar. If you test via Maven/Surefire, you have a simple flag to do the same: http://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html
I saw this somewhere, but I don't know where. It was basically something in Eclipse that was a feature when debugging that highlighted the code as it went through the code. I need this because I have decompiled a huge library, and I need to know how specific features are created.
Thanks,
Neil
F5 key : Executes the currently selected line and goes to the next line in your program. If the selected line is a method call the debugger steps into the associated code.
More details in this link
I'm debugging the JAVA code in Eclipse. Let's say there are 2 breakpoints inside the iterative loop. How to go directly to the breakpoints, while skipping the rest of the code at each iteration?
Press F8 (which is also Resume button),that will take you to the break point. From there debug each line with F6.
If you want to go to next break point press F8.
Use the resume button on the debug bar in your IDE. Please see picture attached
F8 used for Next Debug BreakPoint.
F6 for going line by line after breakpoint.
F7 steps out of currently executed method.