Attaching source to a JAR file

You can attach source to a JAR file to enable source-level stepping and browsing of classes contained in a binary JAR file. Unless its source code is attached to a JAR file in the workbench, you will not be able to view the source for the JAR file.
To attach source to a JAR file:
    Select Properties from the pop-up menu of the project. The Properties page opens.
    Select the Java Build Path page and click the Libraries tab.

    Select the JAR file to which you want to attach source.

    Click the Attach Source button to bring up the Source Attachments dialog. In the Attachments dialog, you can associate the JAR file with another archive (either a JAR or a ZIP file).

    In the Archive field, type or browse to select a file containing source code for the JAR file. The source archive can be either in the workbench or in the file system.

    In the Root Path field, type or browse to select the prefix path to the source code stored inside the archive. If you click Browse, you can browse the contents of the JAR and select its root. Specifying the proper root path is critical to locating the source for a type. A common prefix is src. For example, when looking for the source of java.lang.Object, then you would browse to src/java/lang/Object.java (in this example, src is the prefix).

    Click OK.

Related concepts

Java development tools (JDT)

Related tasks

Attaching source to variables
Creating a new JAR file
Stepping through the execution of a program

Related reference
Java Build Path
Source Attachment dialog
 

Copyright IBM Corporation 2000, 2002. All Rights Reserved.