Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 -->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 eclipse error

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. enter image description here It would to great if someone can help me resolve this issue.

Thanks in advance.

like image 869
Akh Avatar asked Mar 13 '11 08:03

Akh


People also ask

How do I read a .class file in Eclipse?

Clicking anywhere on the class name that we want to open and pressing F3. Clicking anywhere on the class name and going to the menu under Navigate > Open Declaration.

How do I decompile a .class file?

In order to decompile class file, just open any of your Java projects and go to Maven dependencies of libraries to see the jar files included in your project. Just expand any jar file for which you don't have the source attached in Eclipse and click on the . class file.

How do I debug in Eclipse?

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.


2 Answers

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.

like image 86
David Conrad Avatar answered Oct 17 '22 11:10

David Conrad


This blog posts give a comprehensive list of points to check

Follow the steps if you are compiling using Eclipse IDE

enter image description here

  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.
like image 2
VonC Avatar answered Oct 17 '22 09:10

VonC