开发者

How to debug .class files in ECLIPSE?

I am using Eclipse 3.5 and I attached the src.zip to my global settings in Eclipse. Windows--> Preferences -开发者_StackOverflow中文版->Java -->Installed JREs -->rt.jar - Source attachment - ...../jdk/src.zip

I am successfully able to step in the java core library .class files and view the source code. I building a Class which uses the LinkedList and I have set a breakpoint inside the LinkedList class.

When I debug the breakpoints in my source code (my projects) are working good but when I need to step into the java core lib .classes I get the following error in my Eclipse

How to debug .class files in ECLIPSE?

Unable to install breakpoint in java.util.LinkedList due to missing line Number attributes. Modify complier options to generate line number attributes.

I checked my complier settings in Preferences and found all options checked true.

How to debug .class files in ECLIPSE?

It would to great if someone can help me resolve this issue.

Thanks in advance.


You may have the compiler set to include debugging information in YOUR class files, but the class files in rt.jar weren't compiled that way. You need to either recompile all the source for the classes in rt.jar (not for the faint of heart), or download a debug build of the jdk.


This blog posts give a comprehensive list of points to check

Follow the steps if you are compiling using Eclipse IDE

How to debug .class files in ECLIPSE?

  1. Go to windows > preferences > Java > compiler screen.
  2. Make sure that add line number attributes to generated files (used by debugger) check box is checked.
  3. Build again and try adding a breakpoint ahd hope it should work for you.

Note for ant builds

Follow the steps if you are compiling using ANT utility:

  1. Check the build.xml file and make sure that debug attribute is set to true in javac task
  2. Also, if you are using JBoss as an app server, then make sure that you have already opened a port for socket binding of remote machine connection. If not then just ensure that C:/jboss/bin/run.bat has an entry with:
    "set JAVA_OPTS=%JAVA_OPTS% -Xdebug –Xrunjdwp:transport=dt_socket,address=5000,server=y,suspend=n" for opening port 5000 to listen all socket connections for debug/remote java application.
  3. Build again and try adding a breakpoint ahd hope it should work for you.


You should not use a JRE with a JDR src attached as the JRE classes are not well suited for debugging.

Let Eclipse search for Java environments and then select the JDK from the resulting list. This Java environment will have the src.zip attached correctly and you should be able to investigate.

Note that even JDK classes do not have full debugging information available, so you cannot see local variables etc.

(Also, the Compiler settings panel only applies to your code. The JRE classes are pregenerated and the panel does not influence them).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜