9

The help for Java in Eclipse (ordinary Java development, not Android), is set to an online URL at Oracle's server, linked to http://docs.oracle.com/javase/6/docs/api/. However, with one specific computer, I cannot be online during a Java class I teach. So I want to use a local help.

I tried the following:

  • Open the windows - preferences - java - installed jre
  • select the 1.7 runtime, and there the rt.jar
  • press Javadoc location.

There I see the link to the online help. I tried to use the source archive instead, the src.zip folder in the JDK directory. But that does not work. The source does not contain compiled Java doc anyway.

Do I have to download the API docs? And if, where?

5 Answers 5

6

Of course, I had already installed a JDK with a source. On the machine I found a JRE7 and JDK1.7xxx, and the projects use the JRE7.

  1. In Window - Preferences - Java - Installed JRE I found a link to the JRE7, which does not contain sources or a Javadoc.

  2. So I pressed "Edit" and browsed the directory to the JDK1.7, then pressed "Restore Default". This will change the JRE system libraries to the JDK. The Javadoc locations for rt.jar and the other jars is now at Oracle, but nevertheless the installed src.zip is used, if there is no internet connection.

Alternatively, it is indeed possible to attach the src.zip file (file!) to the rt.jar of JRE7.

Sign up to request clarification or add additional context in comments.

1 Comment

I like your answer. +1 for "Restore Default".
3

You can download the Java 7 javadoc from

http://www.oracle.com/technetwork/java/javase/documentation/java-se-7-doc-download-435117.html

4 Comments

This worked, albeit not completely. I downloaded this, set it as the javadoc archive for rt.jar and tried hovering the mouse over "println". It says "no attached source or javadoc cannot be found". But marking "println", F1, and selecting javadoc now works. Still strange.
There is more than Javadoc inside. You must unpack it and point to the Javadoc subfolder.
How did you get that link. I would like to have the same for java-ee but can't get a single downloadable file?
Rather than unpacking it, I think you can just use the "Javadoc in archive" option when you set Javadoc Location, and then set the "path within archive" to something like docs/api.
1

I encountered this issue. It was because the JRE I was using was not the JDK's JRE.

First, update your default JRE:

  • In menu, Window > Preferences > Java > Installed JREs
  • Ensure your JDK's JRE is used. If not, add it by:
    • Add > Standard VM > Point "JRE Home" to <JDK directory, not ./bin> > OK
    • In menu, Window > Preferences > Java > Installed JREs > Execution Environment
    • Ensure your newly added JDK JRE is the default JRE for your selected Java environment

Then, update your existing project to use that JRE:

  • In menu, Project > Properties > Java Build Path > Libraries
  • Scroll to the bottom, where you see the JRE System Library
  • Click it, then the Edit button
  • Modify the selection (either execution environment or alternate JRE) to point to your JDK JRE
  • Click Finish

You should have JavaDocs for the JRE library now! 😊☕

If not, you may need to refresh the JavaDoc settings by going Window > Preferences > Java > Compiler > Javadoc, and uncheck/apply/recheck/apply the Process Javadoc comments checkbox.

Comments

0

There are different options (as @siegi and @Thorbjorn_Ravn_Andersen have told), and it depends, on what you want to do:

  • If you just want to read the JavaDoc of one the API methods you are using, if should be sufficient to read the source code (as mentioned by @siegi), or to open the JavaDoc view and read there a more polished version of it.
  • You may browse the downloaded JavaDoc API as mentioned by @Thorbjorn.

However, in a class I would like to tell people to use their IDE all of the time, so I think browsing the source online is much more natural (for a Java developer), and you are pretty sure that you see the documentation that was written to the sources you are using.

If you want to get some overview of packages or classes, it may be more convenient to use the API in a browser.

2 Comments

The class can access the internet, so they do not have the problem. I can connect to the WLAN with my notebook too, and use the internet via vpn. OK. Maybe we should accept the omnipresense of the internet nowadays.
You know of the Shift-F2 key in Eclipse?
0

If I remember correctly you don't need the API docs at all if you have src.zip available and set up. Eclipse should pick up the Javadoc from the sources as it does with your own code.

Edit: How to setup src.zip:

  1. Open the "Installed JREs" preference pane
  2. Click "Edit…" for your JRE
  3. For each desired library click "Source Attachment…" and select your the src.zip file.

4 Comments

Only, that it doesn't. At least not the way, I included the source in the Javadoc location. Strange.
@Rene Try to not add src.zip to the Javadoc location but to attach it as source to your JRE libraries.
I tried. It did not work. However, see my comment below. Maybe it is a problem of the hovering algorithm.
Just install a JDK and set Eclipse to use it for your project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.