Is there an easy way to attach source in Eclipse?
I'm a big fan of the way Visual Studio will give you the comment documentation / parameter names when completing code that you have written and ALSO code that you are referencing (various libraries/assemblies).
Is there an easy way to get inline javadoc/parameter names in Eclipse when doing code complete or hovering over methods? Via plugin? Via some setting? It's extremely annoying to use a lot of libraries (as happens often in Java) and then have to go to the website or local javadoc location to lookup information when you have it in the source jars right there!
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 :)
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".
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.
An easy way of doing this is :
Download the respective SRC files/folder.
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".
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.)
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"
3)
4) Navigate to C:\Program Files\Java\jdk-9.0.1\lib\src.zip
5) Click OK Now you should see the source code.