2

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?

Ted Hopp
  • 232,168
  • 48
  • 399
  • 521

2 Answers2

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.

Chris Dennett
  • 22,412
  • 8
  • 58
  • 84
  • Well, the library properties in the repaired project (as well as other Java projects) point to the online Javadocs. Also, `src.zip` was not missing. To test your theory, I tried removing `src.zip` from my JDK directory and restarting Eclipse. The Javadocs still pop up fine in Eclipse. Also, if I show the Javadoc in a Javadoc window (instead of a pop-up) and then select "Open Attached Javadoc" from the context menu, it opens a Web Browser window displaying the on-line Javadoc. – Ted Hopp Aug 08 '11 at 22:23
0

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

metator
  • 397
  • 3
  • 5