No source attachment in Java

10,472

Solution 1

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.

Solution 2

hope I got you right:

try to right-click the jar in the references jar tab and go to Preferences -> Javadoc.

choose the right location to the correct javadoc and press "Validate" afterwards

Solution 3

Jar files can be built with or without source code. It's normal for 3rd party applications to produce a binary jar and a source jar, but it isn't required. The message is telling you that it doesn't know where the source code is for the library you are using. It's been a long time since I've done this in eclipse, but there is a way in the project settings to point each library jar to the corresponding source location (which can be a jar, zip file or directory).

Here are a couple of references

Share:
10,472
Whizzil
Author by

Whizzil

Updated on June 04, 2022

Comments

  • Whizzil
    Whizzil almost 2 years

    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.