Attaching Source Code to a JAR File

See Also

When you add a JAR file or folder of compiled classes to a project's classpath, it is often useful to add the source files for those classes so that you can view their contents when working with them. Attaching source code to a JAR file or compiled classes folder lets the IDE know where to find the source code for those classes. You can then step into the source files when debugging and open the source files with the Go To Source command.

To attach source code to a JAR file or compiled classes folder:

  1. Choose Tools > Libraries from the main menu.
  2. In the left pane of the Library Manager, select the project library within which the JAR file you want to add the source code to is located.
  3. If the JAR file or classes folder for which you want to add the source code has not already been added to a registered library, create a new empty library using the New Library button. Next, in the Classpath tab click Add JAR/Folder and specify the location of the JAR file containing the compiled class files.
  4. In the Sources tab, click Add JAR/Folder to add the folder or archive file containing the source code.
  5. Click OK to exit the Library Manager.

    The IDE adds the selected JAR files and source code to the specified library and automatically registers the source code in every project that has that JAR file on its classpath.

To attach source code for a Java platform:

  1. Choose Tools > Java Platforms from the main menu.
  2. Select the platform in the left pane of the dialog box.
  3. In the Sources tab, add the folders or archive files containing the source code.
See Also
Setting the Target JDK
Managing the Classpath
Starting a Local Debugging Session
Starting a Remote Debugging Session

Legal Notices