Source attachments
To browse the source of a type contained in a binary JAR you can attach a source archive to this JAR. The editor will then show the source instead of a the decompiled code.
Having the source attachment set the debugger can offer source level stepping in this type.
The Source Attachment dialog can be reached in several ways:
- Select a JAR in the Package Explorer and choose Properties > Source Attachment from the context menu or the File menu
- Open the Java Build Path page of a project (File > Properties > Java Build Path). On the library page select a JAR and press Attach
Source
Open an editor on a class file. If the source attachment has not already been configured for this JAR, the editor contains a button Attach
Source
To configure the source attachment the location of an archive that contains source files has to set and archive's root path has to be specified. Specifying the proper root
path is critical to locating the source for a type. For example, when the Java development tools are looking for the source for java.lang.Object and the Object.java
file is located in the archive under src/java/lang/Object.java, then src is the prefix.
Depending of how a JAR was contributed to the classpath, you can see different types of Source attachment dialogs:
JAR
- In the Archive field, type or browse to select an archive file containing source code for the JAR file.
- 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 to select its root.
Variable
- In the Archive Variable Path field, a variable path points to the source attachment path. In a variable path the first segment describes a
variable (which will resolve to a directory or file), the rest is an optional path extension (e.g.MYVARIABLE/src.jar ). The path extension is only needed if the
variable points to a directory but not to a file. Use either the Variable button to select or edit an existing variable and the Extension button to select the extension path. The Extension button is only enabled when the variable can be extended (points
to a directory)
- In the Root Variable Path field, a variable path points to the source attachment root path. In a variable path the first segment describes a
variable (which will resolve to a directory or file), the rest is an optional path extension. Use either the Variable button to select or edit
an existing variable and the Extension button to select the extension point. The Extension button is only enabled
when the variable can be extended (points to a directory).
JRE_SRC and JRE_SRCROOT are reserved variables that point to a JRE selected in the Installed JREs preference page (Window > Preferences > Java > Installed JREs). Go to this preference page to configure the source attachment for the JRE's library..
Container
Source attachments coming from container entries have to be configured on the container's configuration page. For the JRE container this is the Installed JREs preference page (Window > Preferences > Java > Installed JREs).

Build classpath

Working with build paths
Attaching source to variables
Attaching source to a JAR file
Installed JREs preferences
Java Build Path properties
