How do I view and debug JDK source code in Eclipse?
Author: Deron Eriksson
Description: This Java tutorial describes how to debug through Java Development Kit source code in Eclipse.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1

Page: < 1 2 3 >

(Continued from page 1)

Now, once again we can click on String in our Test class and click F3.

Test class

This time, F3 actually brings up the source code for the String class. This is because the JDKW includes source code (in our example, this is at C:\jdk1.5.0_09\

String class source code

As an example of debugging a JDK class, let's add a Vector to our Test class.

Adding a Vector to Test

If we hit F3 on Vector, this brings up the Vector.class file. In this example, we set a breakpoint in the constructor.

Vector class source code

Next, we can fire up our Debug configuration that calls the Test class.

Debugging Test class

We can see in the stacktrace that the code has hit the breakpoint in the constructor of the Vector. We can then perform various actions like stepping into, stepping over, and stepping out of code, and we can inspect our various variables as this happens.

Breakpoint in Vector constructor

(Continued on page 3)

Page: < 1 2 3 >