How to solve "This element has no attached source and the Javadoc could not be found in the attached Javadoc"?
Asked Answered
L

9

21

I don't get the exact method to do this. I want a method not for a single project for all projects in eclipse. Please tell me how to solve this problem.

Let answered 24/5, 2011 at 5:43 Comment(3)
do you have the source or the javadoc for the library you want?Hearn
please try to accept answers to your questionsBorer
As Thorbjørn Ravn Andersen suggested above, try to VALIDATE zip file before Apply. If that fails, try to access/validate your .zip file from another local drive/path. Worked for me.Dynameter
H
20

This is for a jar on your classpath in Eclipse, where you have

  1. attached a javadoc zip which Eclipse for some reason dislikes.

  2. NOT attached a valid source jar.

The easiest way is to 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. Remember to use the "Validate" button to ensure that it is correctly set up.

Honorary answered 24/5, 2011 at 5:54 Comment(6)
If your using mutliple jars sometimes the order of imports may affect the javadocs Simply go to Properties->Java Build Path->Order and Export and move your libraries around until the javadocs appear PS: I know this post is really old but this post is really high on google searchRapp
@Rapp if you have the same class multiple times on the Classpath you may have more interesting problems than this.Chronograph
If it's a Maven project, expand {package-name} > Java Resources > Libraries > Maven Dependencies, right-click the jar, click Maven > Download JavaDocShroud
@Rapp - Worked for me, great info.Ichabod
@PhilipRego There is no standard way to locate a javadoc archive for a given jar file. Some projects have their javadoc available on a webserver. Then give the URL as the location. Some Maven jars have javadocs, where the described method will work, and others do not.Chronograph
@PhilipRego The answer is six years old. It was correct at the time of writing.Chronograph
V
9

Akki's problem also plagued me for much too long. But the fix is super easy.

If you're using Eclipse (Neon), and

If you have Maven (highly recommended) with the Eclipse plugin to handle it, and

If your project is a Maven project (it can be converted into one **),

Then you can easily add Javadocs to all your jar dependencies at once (if you're also using Spring Boot, there may be about 75 of them!) by doing the following:

  • Right click on your project (in the Project Explorer),
  • Hover over "Maven" to get a submenu, and
  • Select "Download JavaDocs".

You should see in the lowest right hand corner a status bar that says "downloading sources and javadocs" and a progress bar.

** To mavenize your project:

  • Right click on it in the Project Explorer,
  • Hover over "Configure" to get a submenu, and
  • Select "Convert to Maven Project".
Volumetric answered 18/8, 2016 at 15:12 Comment(2)
Those who have javadoc.Chronograph
Simple and effectiveBeseem
A
7

This happened to me after I moved my Android files from one PC to a new PC: I simply copied the folder from P:\Android\ to C:\Android\

To fix the error (using Eclipse), right-click the library (in my case android.jar) in your project. Click "Properties", click "Javadoc Location", and fix the Javadoc location path.

For example, I changed it from "file:/P:/Android/android-sdk-windows/docs/reference" to "file:/C:/Android/android-sdk-windows/docs/reference"

Then click "Validate". Then click "Apply". Then click "OK"

now hovering over a method or constant gives me the API info again :-)

Anthropologist answered 10/8, 2011 at 23:33 Comment(0)
B
4

Assuming you're using Eclipse as an IDE, the statement (provided in your question title) means that the IDE cannot find a javadoc comment to display the method/class/attribute description (usually shown when hovering a class/method/attribute). To fix this, you need to attach a jar or zip that contains the javadoc comment. This is usually a source code for a specified class (as it contains comments, if the programmer provided comments) and the IDE will extract the javadoc comments out of it and display it appropriately.

Hope this helps.

Brood answered 24/5, 2011 at 5:49 Comment(0)
R
4

This problem happened to me also when I upgrade to Eclipse Photon version. Use this following flow to attach Javadoc manually.

Go to Eclipse >> Window >> Preferences >> Java >> Installed JREs >> Select "JRE" and Edit >> Choose "C:\Program Files\java...\lib\jrt-fs.jar" >> Choose "Source attachment" and Source attachment... >> Choose External location >> Go to the path of "src" like "C:/Program Files/Java/jdk-10.0.1/lib/src.zip" >> Ok >> Finish >> Apply and Close.

Radiator answered 7/7, 2018 at 19:44 Comment(0)
S
2

I know this is a very late answer, but this will help if anyone is using a gradle project.

change your build.gradle to include the following:-

apply plugin: 'java'
apply plugin: 'eclipse'

eclipse {
    classpath {
        downloadJavadoc = true
        downloadSources = true
    }
}

This will add both java source and javadoc.

If this still doesnot work then right click on the Project>Build PAth>Configure Build Path>order and Export > and bring Web App libraries to the bottom Then Close the project and reopen it

Shrunk answered 17/2, 2017 at 6:59 Comment(0)
S
1

Using Eclipse 4.2.2 on OSX 10.7.5, after I got the lib into "referenced libs", I had to then right click it > Build Path > Configure Build Path > go to Order and Export tab, then highlight the lib I want and move it up to the top with the "up" button. I didn't notice any difference with the checkbox checked or unchecked.

That's what got it working for me.

Spoken answered 16/4, 2013 at 21:47 Comment(0)
S
0

Also, after doing one of these in the UI, you'll see your .classpath file has changed- that jar now has a sourcepath attribute.

It's probably easier to quit eclipse and edit the rest by hand. Remove the foo-source jar files as separate jars and add them as sourcepath attributes on each classpathentry element.

Strephonn answered 21/6, 2017 at 0:47 Comment(1)
I meant to add this after another comment, which I don't see. Go to project > properties > java build path and in the libraries path, click on the arrow to the left of a jar that has a source file. > foo.jar It will open to show a source-attachment subelement and a few more. Click on the source-attachment element and then click the Edit button and browse to its source jar file and Apply it. Then save it, quick eclipse, and edit the rest in the .classpath file...Strephonn
F
0

To Solve this issue for all projects, the best way is to create a user library and import all your external JARs into that library. Then for each JAR add the javadoc URL into Javadoc location field. So this way whenever you need to import the JARs under build path, always use user library. so you will have javadoc location already configured.

Flashback answered 22/5, 2020 at 10:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.