开发者

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

开发者 https://www.devze.com 2023-03-08 09:23 出处:网络
I don\'t get the exact method to do this. I want a method not for a single project开发者_JS百科 for all projects in eclipse. Please tell me how to solve this problem.This is for a jar on your classpat

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


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.


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".


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


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.


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.


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


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消