it may seem like overkill, but if you use maven and include source, the mvn eclipse plugin will generate all the source configuration needed to give you all the in-line documentation you could ask for.


another thought for making that easier when using an automated build:

when you create a jar of one of your projects, also create a source files jar:

instead of going into the build path options dialog to add a source reference to each jar, try the following: add one source reference through the dialog. edit your .classpath and using the first jar entry as a template, add the source jar files to each of your other jars.

this way you can use eclipse's navigation aids to their fullest while still using something more standalone to build your projects.


i was going to ask for an alternative to attaching sources to the same jar being used across multiple projects. originally, i had thought that the only alternative is to re-build the jar with the source included but looking at the "user library" feature, you don't have to build the jar with the source.

this is an alternative when you have multiple projects (related or not) that reference the same jar. create an "user library" for each jar and attach the source to them. next time you need a specific jar, instead of using "add jars..." or "add external jars..." you add the "user library" that you have previously created.

you would only have to attach the source once per jar and can re-use it for any number of projects.


for those who are writing eclipse plugins and want to include the source... in the feature exportwizard there is an option for including the source: enter image description here


just click on attach source and select folder path ... name will be same as folder name (in my case). remember one thing you need to select path upto project folder base location with "\" at suffix ex d:\myproject\


another option is to right click on your jar file which would be under (your project)->referenced libraries->(your jar) and click on properties. then click on java source attachment. and then in location path put in the location for your source jar file.

this is just another approach to attaching your source file.


if you build your libraries with gradle, you can attach sources to the jars you create and then eclipse will automatically use them. see the answer by @michaeloryl how to build sources jar with gradle.

copied here for your reference:

jar {
    from sourcesets.main.allsource

the solution shown is for use with the gradle java plugin. mileage may vary if you're not using that plugin.


  1. put source files into a zip file (as it does for java source)
  2. go to project properties -> libraries
  3. select source attachment and click 'edit'
  4. on source attachment configuration click 'variable'
  5. on "variable selection" click 'new'
  6. put a meaningful name and select the zip file created in step 1


  1. click on the java code you want to see. (click on list to open if you want to check source code for java.util.list)
  2. click on "attach source" button.
  3. you will be asked to "select the location (folder, jar or zip) containing the source for rt.jar).
  4. select "external location" option. locate the file.
  5. path for is : *\java\jdk1.8.0_45\


when you add a jar file to a classpath you can attach a source directory or zip or jar file to that jar. in the java build path properties, on the libraries tab, expand the entry for the jar and you'll see there's an item for the source attachment. select this item and then click the edit button. this lets you select the folder, jar or zip that contains the source.

additionally, if you select a class or a method in the jar and ctrl+click on it (or press f3) then you'll go into the bytecode view which has an option to attach the source code.

doing these things will give you all the parameter names as well as full javadoc.

if you don't have the source but do have the javadoc, you can attach the javadoc via the first method. it can even reference an external url if you don't have it downloaded.


i've found that sometimes, you point to the directory you'd assume was correct, and then it still states that it can't find the file in the attached source blah blah.

these times, i've realized that the last path element was "src". just removing this path element (thus indeed pointing one level above the actual path where the "org" or "com" folder is located) magically makes it work.

somehow, eclipse seems to imply this "src" path element if present, and if you then have it included in the source path, eclipse chokes. or something like that.


yes there is a easy way... go to ... and download the zip file. then attach this to the eclipse. give the path where you have downloaded the zip file in eclipse. we can then browse through the source.


1) hold control+ left click on the method you want to see. then eclipse will bring you to the source not found page.

2) click on "attach source" enter image description here

3) enter image description here

4) navigate to c:\program files\java\jdk-9.0.1\lib\

5) click ok enter image description here now you should see the source code.


an easy way of doing this is :

  1. download the respective src files/folder.

  2. in the eclipse editor, ctrl+click or f3 on a method/class you need the source for. a new tab opens up which says "no attached source found".

  3. click the "attach sources" button, click the "attach source folder" button, browse to the location of the downloaded src folder. done!

(p.s : button labels may vary slightly, but this is pretty much it.)


up until yesterday i was stuck painstakingly downloading source zips for tons of jars and attaching them manually for every project. then a colleague turned me on to the java source attacher. it does what eclipse should do - a right click context menu that says "attach java source".

enter image description here

it automatically downloads the source for you and attaches it. i've only hit a couple libraries it doesn't know about and when that happens it lets you contribute the url back to the community so no one else will have a problem with that library.


short answer would be yes.

you can attach source using the properties for a project.

go to properties (for the project) -> java build path -> libraries

select the library you want to attach source/javadoc for and then expand it, you'll see a list like so:

source attachment: (none)
javadoc location: (none)
native library location: (none)
access rules: (no restrictions)

select javadoc location and then click edit on the right hahnd side. it should be quite straight forward from there.

good luck :)

Related Query

More Query from same tag