Search code examples
javaeclipsejarjavadoc

No source attachment in Java


I am trying to use an external .jar file in my project. I have put that .jar file in my project's /lib folder, and I have referenced it in the build path. However, when I try to use it in code, I can't get the javadoc for it, nor I can see the actual code from the referenced classes. It says it has no source attachment. What is it meant by source attachment? I do have a javadoc folder that came with it, but when I attach it to my build path, it still reports it could not found the javadoc for the classes. Any ideas on that?

I want to be able to see the javadoc.


Solution

  • The .jar file is the generated packed classes of the java code. Some jars will come with java doc and code and others won't.

    For recent Eclipse versions:

    right-click the jar in question (in the referenced jars, not the physical jar) and choose Preferences -> Javadoc. Here give a correct location (zip/URL) to the correct javadoc. (Select Validate!)

    For older Eclipse versions:

    First: Navigate to the jar itself in the Eclipse project explorer (to the left) and try to open aclass of the jar. Then, you will see the warning that it has no source attachment, and a button to attach the source code.

    Then, push the button, select "external folder" and then navigate to the folder with source you already have.