Mysterious Eclipse javadoc problem

空扰寡人 提交于 2019-12-24 03:59:32

问题


I had a problem with finding Java docs in Eclipse. I seem to have fixed the problem, but I'm posting this for two reasons: I would like to know why I had the problem in the first place and perhaps my method of fixing it might be useful to someone else having a similar problem.

I created a simple Java project in Eclipse (Helios on Windows 7) and selected the JavaSE-1.6 JRE. Then I created a source file and imported java.util.GregorianCalendar. When I hovered over GregorianCalendar, I was getting the message:

This element has no attached source and the Javadoc could not be found in the attached Javadoc

None of the methods of GregorianCalendar seemed to have any Javadoc, either. Other standard Java classes (even others in java.util, like ArrayList) didn't have this problem; only GregorianCalendar. Everything seemed set up properly in the project settings. The Javadoc location set in the Java Build Path was http://java.sun.com/javase/6/docs/api/.

I managed to restore correct behavior by temporarily switching to JavaSE-1.7 and then back. Evidently something got reset and all is well. While I'm happy that things are now working, I don't like being clueless as to how they got messed up in the first place.

Can anyone provide any insights into this?


回答1:


I think general support relies on the presence of a src.zip in your JDK directory, which is detected when you autosearch a directory for Java installations. It could be missing. Not sure if online Javadocs are used.




回答2:


I'm using Eclipse Juno on a Windows 7 64-bit (with a 32-bit JDK) but i think it will also apply to your Eclipse version:

  1. Download JDK docs zip file to your Desktop folder;
  2. Right-click on the file, choose Properties and unblock it;
  3. Move the file to a location of your choice. I normally move it to the JDK folder;
  4. Open Eclipse and go to Window->Preferences->Java->Installed JREs;
  5. Select your JDK installation and press Edit;
  6. Select the rt.jar file and click "Javadoc Location..." button;
  7. Select the "Javadoc in archive" radio button;
  8. Set the archive path by browsing to the JDK docs zip file;
  9. Set the "Path within archive" to "docs/api" (without the quotes).

Enjoy! ;)



来源:https://stackoverflow.com/questions/6985686/mysterious-eclipse-javadoc-problem

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