Missing basic JavaDoc in Eclipse

徘徊边缘 提交于 2019-12-05 13:01:19

问题


Up to a few days ago, Eclipse was working fine in locating the javadoc for base classes such as Java.io.File. Recently, though, hovering over these classes only yields a message indicating that the source and javadoc are missing:

"Note: This element has no attached source and the Javadoc could not be found in the attached Javadoc."

I couldn't for the life of me locate the option that would let me reselect the location of the basic documentation. Does anyone know how to fix this?


回答1:


Expand your JRE System library and find rt.jar (classes.jar for Mac OS X). Right click, and select 'Properties'.

You can then specify the Javadoc location (as well as the source location).




回答2:


The best way to do it is Go to Project > Properties > Java Build Path > Libraries and expand JRE System Library [your jre version] then, rt.jar. Select Source attachment, click Edit…. Select the source code file (External File…) and press OK.

Other ways to attach java source code is mentioned in this link

http://www.cavdar.net/2008/07/14/3-ways-of-jdk-source-code-attachment-in-eclipse/




回答3:


I encountered this problem now a couple of times too. It's especially annoying if you have a lot of projects in your workspace and you don't want to set the javadoc locations for each project.

Referencing the online documentation works well indeed, and there is a way to do that globally for all Java libraries:

  • Go to: Window -> Preferences
  • Expand: Java -> Installed JREs
  • Select your default Java installation
  • Press ''Edit''
  • Select all the JRE system libraries
  • Press ''Javadoc Location...''
  • In the Javadoc location path put in the path to the online documentation. For Java 8 for example this is http://docs.oracle.com/javase/8/docs/api/. (If you press ''Validate...'' it will tell you if it is a valid javadoc location.)
  • Press ''OK'', then ''Finish'', then ''OK''

And here you have some images:

And your basic Java javadoc is ready to go.




回答4:


Press ctrl+click (or command+click if you're on a Mac) on any method which doesn't have javadocs. For example, in this line:

System.out.println();

... assuming that no javadocs are available for println, control-clicking on println will open a new tab with a button labeled "Attach Source...". And that's it!




回答5:


I had the same problem.

I uninstalled eclipse, removed all eclipse specific data from my user's home- and application data directory, uninstalled all Java JREs and JDKs but nothing helped.

The solution on my system was to change the protocol in the JavaDoc URL from HTTP to HTTPS

e.g. for JRE 7 i changed the URL from http://docs.oracle.com/javase/7/docs/api/ to https://docs.oracle.com/javase/7/docs/api/

(use the steps mentioned by Terry and replace the 'http' with 'https')



来源:https://stackoverflow.com/questions/10004789/missing-basic-javadoc-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!