Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I step into/over Java source code in NetBeans Debugger?

I have a Java project which I am debugging in NetBeans (versions 6.8 and 6.9) and I am unable to step into or step over the code. I can only set breakpoints and then continue to the breakpoints. This is not very convenient. I'd like to be able to step through the code without setting breakpoints everywhere and running to them. I am attaching to the JVM because it cannot be started in NetBeans (it is started by a C program via JNI). Is there an issue related to attaching to a JVM?

If I do happen to try and step into/over a line of code, the debugger hangs (pause button is disabled) and the only option is to detach/end the debug session.

like image 313
bubbadoughball Avatar asked Jul 28 '10 04:07

bubbadoughball


People also ask

How do I step over in NetBeans?

According to NetBeans 6 in Simple Steps (p. 193), Step Over (F8): Executes the current line then moves to the next line. If any line contains call to a method or constructor then executes the entire method or constructor without stepping into them.

How do I Debug a Java project in NetBeans?

Taking a GUI Snapshot or, click the Debug button in the toolbar to start the debugging session. Alternatively, right-click the project node in the Projects window and choose Debug.

How do I run a Java program in debug mode?

A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead. Either actions mentioned above creates a new Debug Launch Configuration and uses it to start the Java application.


1 Answers

When your breakpoint has been hit and you have broken into your java code. Try:

  1. Window -> Debugging -> Sources
  2. Add/Confirm the root directory of your java sources is set as a 'Source Root'.
like image 53
Alistair Sutherland Avatar answered Sep 22 '22 13:09

Alistair Sutherland