Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an easy way to attach source in Eclipse?

Tags:

java

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!

like image 641
Alex Argo Avatar asked Sep 23 '08 16:09

Alex Argo


People also ask

What is link source in Eclipse?

In this case, I am talking about the 'Link Source' feature in the Project Properties tab. Most experienced Eclipse users will at some point wander through the project properties, for instance when certain libraries are not found by the compiler, or when a plugin project starts to behave unexpectedly.

How do I detach a source in Eclipse?

Open the . classpath file and delete the source attachment part. Or in the Build Path control panel, find the jar file and remove the source attachment (it is one of the detailed options there). m2e automatically adds the attached source even after you remove it.


2 Answers

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 :)

like image 135
Henry B Avatar answered Oct 23 '22 01:10

Henry B


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.

like image 24
tterrace Avatar answered Oct 23 '22 01:10

tterrace