Rene
Rene

Reputation: 3776

javadoc location for eclipse offline

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:

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?

Upvotes: 9

Views: 31925

Answers (5)

Rene
Rene

Reputation: 3776

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.

Upvotes: 6

Cardin
Cardin

Reputation: 5487

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.

Upvotes: 1

siegi
siegi

Reputation: 5996

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.

Upvotes: 0

mliebelt
mliebelt

Reputation: 15525

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.

Upvotes: 0

Related Questions