开发者

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

开发者 https://www.devze.com 2023-01-09 08:26 出处:网络
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

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 h开发者_开发百科appen 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.


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'.


After losing so much time setting breakpoints and running or using Debug\Debug Project, I got lucky. In the Debug menu, I just selected 'Step Into' and the IDE began running my code one step at a time, highlighting the active line and graying out the highlight when a user response is required. (Using the above suggestion of turning off the Java src code greatly helps too.)


I have seen this behavior in ONE project that came with a JSP book. Step over worked fine in other projects, but in one particular project executing a "Step over" just made it run to the next breakpoint instead of the next line.

I traced down the problem to the differences in debug.classpath property in project.properties file.

Bad project had this: debug.classpath=${build.classes.dir.real}:${javac.classpath}:${j2ee.platform.classpath}

Good projects with working Step over had this instead: debug.classpath=${javac.classpath}:${build.classes.dir}

Changing debug.classpath fixed the problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消