开发者

Mysterious Eclipse javadoc problem

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 properl开发者_如何学Cy 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?


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.


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! ;)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜