26

When writing Java code, I refer extensively to the Javadoc—that is, the Java® Platform, Standard Edition & Java Development Kit Version x API Specification. I know how to read it online from the website, but I would like to download a copy to my computer so that I can read it offline when no Internet connection is available.

How can I download the documentation? Is there a way to "download" the Javadoc (JDK documentation) from an online site to a local file?

The online docs I am using tend to reject clients such as Eclipse, making work difficult, so I need to pull them onto my machine and attach them to my library JAR.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Luke Dowell
  • 271
  • 1
  • 3
  • 4
  • 4
    **Note to those considering voting to close this as seeking resource recommendations: it's not.** To start, it doesn't ask for a recommendation at all; it asks how to solve a problem. [It's completely reasonable for people to recommend tools that solve the problem presented in the question](//meta.stackoverflow.com/a/251605). If *individual answers* are low quality, then that should be dealt with at the level of that specific answer, not by closing the question. Furthermore, [asking where to find the official documentation is not seeking a recommendation](//meta.stackoverflow.com/a/386006). – Cody Gray - on strike Jan 28 '23 at 16:44

13 Answers13

153

Links to JDK documentation

Java SE Download Web Other
21 (Early-Access) Not yet available Javadoc Project page
20 (current) Downloads page Javadoc Doc home
19 (current) Downloads page Javadoc Doc home
18 Downloads page Javadoc Doc home
17 (LTS) Downloads page Javadoc Doc home
16 no longer available Javadoc Doc home
15 no longer available Javadoc Doc home
14 no longer available Javadoc Doc home
13 no longer available Javadoc Doc home
12 no longer available Javadoc Doc home
11 (LTS) Downloads page Javadoc Doc home
10 no longer available Javadoc Doc home
9 no longer available Javadoc Doc home
8 (LTS) Downloads page Javadoc Platform home
Doc home
7 no longer available Javadoc Doc home
6 no longer available Javadoc Doc home

Also of interest:

Nicolas Mace
  • 52
  • 1
  • 6
jfg956
  • 16,077
  • 4
  • 26
  • 34
  • 9
    I end up trawling SO every time I want to download the JDK 6 API documentation in the form of a zip containing the javadocs, so I'm adding this comment in the hopes that it'll make my future searches easier. Thanks! – Conan Jul 31 '13 at 08:07
  • 1
    How did you find those pages? For example the [documentation download page for Java SE 8](https://www.oracle.com/technetwork/java/javase/documentation/jdk8-doc-downloads-2133158.html). When you click on that tab _Documentation_ on that page, you may notice it will bring you to a different page without a possibility to download the docs. I'm not able to find that page myself there unless I have your direct link. – David Ferenczy Rogožan Aug 09 '19 at 11:47
  • 4
    OK, got it, but it's a bit...inconvenient. Go to the [Java SE page](https://www.oracle.com/technetwork/java/javase/overview/index.html), select the _Downloads_ tab and under the _Additional downloads_, there're _Download_ buttons for the docs. If you switch to the _Documentation_ tab, there's no way to download it there. – David Ferenczy Rogožan Aug 09 '19 at 11:56
  • Oracle has removed for JDK 6 and 7. Those links are not working – Vipul Verma Jan 02 '21 at 14:31
  • 1
    Download links for Java SE 12, 13, 14 now redirect to the online version. – Blauelf Jan 13 '21 at 13:57
27
  1. First, make sure they don't already offer an download in zip form or similar.

  2. Then, make sure you are actually allowed to do this (this may depend on where you live, and on any conditions mentioned on the web site from where you want to pull this).

  3. Then, have a look at the Wget tool. It is part of the GNU system, thus included in many Linux distributions, but also available for Windows and Mac, I suppose.

Something like this works for me:

wget --no-parent --recursive --level inf --page-requisites --wait=1 \
   https://epaul.github.io/jsch-documentation/simple.javadoc/

(without the line break; it should be escaped by the \ backslash here).

Look up what each option does in the manual before trying this.

If you want to do this repeatedly, look into the --mirror option. For downloading other websites, --convert-links might also be useful, but I found that is not needed for Javadocs, which usually have the correct absolute and relative links.

This downloads lots of the same copy of the index.html file with appended ?... names (for the FRAMES links on each page). You can remove these files after downloading by adding the --reject 'index.html\?*' option, but they still will be downloaded first (and checked for recursive links). I did not yet find out how to avoid downloading them at all. (See this related question on Server Fault.)

Maybe adding the right recursion level would help here (I didn't try).

After downloading, you might want to zip the resulting directory to take less disk space. Use the zip tool of your choice for this.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Paŭlo Ebermann
  • 73,284
  • 20
  • 146
  • 210
23

For any Javadoc (not just the ones available for download) you can use the DownThemAll addon for Firefox with a suitable renaming mask, for example:

*subdirs*/*name*.*ext*

https://www.downthemall.org/main/install-it/downthemall-3-0-7/

It's possible to use some older versions of the DownThemAll add-on with Pale Moon browser.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
CrouZ
  • 1,721
  • 17
  • 17
  • Updated the links. I don't think it's possible to use in Firefox anymore since they obsoleted all addons, but it should still work with Firefox forks, for example, Pale Moon. – CrouZ Feb 10 '19 at 21:08
  • It might be possible with [Firefox ESR](https://en.wikipedia.org/wiki/Firefox#Experimental_builds_and_ESR). – Peter Mortensen Feb 14 '23 at 07:21
  • @Peter I think you would need to go as far back as Firefox ESR 52, for which support ended 2018. – CrouZ Feb 15 '23 at 23:36
13

You can use something called Dash: Offline API Documentation for Mac. For Windows and Linux you have an alternative called Zeal.

Both of them are very similar. And you can get offline documentation for most of the APIs out there like Java, Android, Angular, HTML5, etc. ... almost everything.

I have also written a post on How to install Zeal on Ubuntu 14.04

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
kushdilip
  • 7,606
  • 3
  • 24
  • 30
9

Update 2019-09-29: Java version 11

The technique below does not now work with Java 11, and probably higher versions: there isn't any way of ignoring multiple "broken links" (i.e., to other classes, other APIs). Solution: keep your javadoc executable file (or javadoc.exe) from Java version 8


There are good reasons for making your own local javadocs, and it's not particularly difficult!

First you need the source. At the time of writing the Java 8 JDK comes with a zip file called src.zip. Sometimes, for unexplained reasons, Oracle don't always include the source. So for some older versions (and who knows about the future) you have to get hold of the Java source in another way. It's worth also being aware that, in the past, Oracle have sometimes included the source with the Linux version of the JDK, but not with the Windows one.

I just unzipped this file... the top directories are "com", "java", "javax", "launcher" and "org". Directory launcher contains no files to document.

You can generate the javadocs very very simply from any or all of these by cd'ing at the command prompt/terminal to the directory ...\src. Then go

javadoc -d docs -Xmaxwarns 10 -Xmaxerrs 10 -Xdoclint:none -sourcepath . -subpackages java:javax:org:com

NB note that there is a "." after -sourcepath

Simple as that. Generating your own javadocs also has two huge advantages

  1. you know they are precisely the right javadocs for the JDK (or any external JAR file) you are using on your system
  2. once you get into the habit, reconstituting your Javadocs is not a tiresome challenge (i.e,. where to go looking for them). For example, I just unzipped a couple of source JAR files whose packages were closely coupled, so their sources were in effect "merged" & then made a single Javadoc from them...

NB Swing is semi-officially dead. We should all be switching to JavaFX, which is helpfully bundled with Java 8 JDK, but in its own source file, javafx-src.zip.

Unzipped, this reveals three "root" packages: com, javafx and netscape (wha'?). These should be manually moved over to the appropriate places under the unzipped src directory (including the JavaFX com.sun packages under the Java com.sun structure). Compiling all these Javadoc files took my machine a non-negligible time. I'd expect to see all the JavaFX source classes in with all the other source classes some time soon.


BTW, the same thinking applies to documenting any and all Java JAR files (with source) which you use. However, all versions of most JAR files will be found with their documentation available for download at Maven Central http://search.maven.org...

PS afterthought:
using Eclipse and the "Gradle STS" plugin: the "New Gradle STS Project" wizard will create a gradle.build file containing the line

include plugin: 'eclipse'

This magically downloads the source JAR file with the executable JAR file (under GRADLE_HOME) when you go

./gradlew build

(Addendum 2020-01-13: if you have chosen not to include the Eclipse plugin in your build.gradle, it would appear that you can go (with the selection on your project in the Project Explorer). Right-click GradleRefresh Gradle Project to get Eclipse to download the source files.)

... giving you an extra degree of certainty that you have got the right src and therefore the right javadoc for the dependency in question.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mike rodent
  • 14,126
  • 11
  • 103
  • 157
5

I have used Javadoc packaged by Allimant since I was in college.

The Javadoc is in the CHM format (standard Windows help format), so it's the best viewed when you're using Windows.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
dns
  • 2,753
  • 1
  • 26
  • 33
2

For the download of latest Java documentation (JDK 8u77) API

Navigate to http://www.oracle.com/technetwork/java/javase/downloads/index.html

Under Addition Resources and Under Java SE 8 Documentation, click the Download button.

Under Java SE Development Kit 8 DocumentationJava SE Development Kit 8u77 Documentation.

Accept the License Agreement and click on the download ZIP file.

  • Unzip the downloaded file
  • Start the API documentation from jdk-8u77-docs-all\docs\api\index.html

For the other Java versions API download, follow the following steps.

Navigate to http://docs.oracle.com/javase/

From Release dropdown, select either of Java SE 7/6/5.

In corresponding Java SE page and under Downloads left side menu, click JDK 7/6/5 Documentation or Java SE Documentation.

Now on the next page, select the appropriate Java SE Development Kit 7uXX Documentation.

Accept License Agreement and click on Download ZIP file.

Unzip the file and start the API documentation from jdk-7uXX-docs-all\docs\api\index.html.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
vinsinraw
  • 2,003
  • 1
  • 16
  • 18
1

In this case ... make your own javadocs!

First you need the source. At the time of writing the Java 8 JDK comes with a ZIP file called src.zip. Sometimes, for unexplained reasons, Oracle don't always include the source. So for some older versions (and who knows about the future) you have to get hold of the Java source in another way. It's worth also being aware that, in the past, Oracle have sometimes included the source with the Linux version of the JDK, but not with the Windows one.

I just unzipped this file... the top directories are "com", "java", "javax", "launcher" and "org". Directory launcher doesn't contain any files to document.

You can generate the javadocs very very simply from any or all of these by cd'ing at the command prompt/terminal to the directory ...\src. Then go

javadoc -d docs -Xmaxwarns 10 -Xmaxerrs 10 -Xdoclint:none -sourcepath . -subpackages java:javax:org:com

NB: Note that there is a "." after -sourcepath

It is as simple as that. Generating your own javadocs also has the huge advantage that you know they are precisely the right javadocs for the JDK you are using on your system.

The same applies to documenting any and all Java JAR files (with source) which you use. However, all versions of most JAR files will be found with their documentation available for download at Maven Central...

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mike rodent
  • 14,126
  • 11
  • 103
  • 157
0

JavaFX API documentation

You could download the Mac 2.2 preview release from here and unzip it.

http://www.oracle.com/technetwork/java/javafx/downloads/devpreview-1429449.html

The Javadoc won't quite match 2.1, but it will be close and if you use the preview instead, it will match exactly.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
0

Just liking me:

If you want to get the Java-8 docs into your local workspace, download the latest version of Java-8 docs(Java SE Development Kit 8u371 Documentation);

Or, download the first version of Java-8 docs(JDK 1.1.8 Documentation), which is in Windows Help format, xCHM may help you to use HTMLHelp documentation on your machines while you are Unix or MacOS users;

and you could refer the Org. documents of Java-8 here on Web;

also, the platform home or Doc home of Java-8 this;

But if you want to get the yours version of java-8 docs, I just manually create that my self,

(1)copy and duplicate the src.zip at your java_home into the new directory javasrc created by myself under ~/,

(2)using the target command to generate the your own java-8 docs and move that into the new directory jdk-8-docs created by myself under ~/:

(my subdirectory of java_home:/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/)
cd ~ && mkdir javasrc && mkdir jdk-8-docs && cd javasrc
cp /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/src.zip ../javasrc/src.zip
jar xvf src.zip
(seven subdirectory com, java, javax, jdk, launcher, org, sun)
(subdirectory launcher do not have one java source file)
(The "jdk" and "sun" directories are both part of the Java Development Kit (JDK). )
(They include some of the core Java classes and library files, such as the Java Virtual Machine, )
(Java core class library, Java compiler, and more. Within these directories, )
(you can find implementations of many of the core Java classes, as well as other useful tools and resources. ))
(The "org" directory is one of the common top-level packages in Java programs. )
(In Java, packages are a mechanism for organizing code, grouping related classes )
(together for better management and use. The "org" directory typically contains)
(Java classes created by organizations or institutions, often associated with the)
(name of that organization or institution. )
rm -r src.zip
(if you want your own doc just liking Org, that means only using)
(subpackages `java`, `javax` and `com`, using the below codes)
javadoc -d docs -Xdoclint:all -sourcepath . -subpackages com:java:javax
(The upstairs code generate the jdk-8-docs as subdirectory `docs`)
mv docs ../jdk-8-docs

Finally, using your local Browser open your own generated jdk-8-docs via inputing file:///Users/yq/jdk-8-docs/index.html at your Brower's url.

In short, navigate to file:///Users/yq/jdk-8-docs/index.html in your brower, and add this pages to your bookmarks.

Vittore Marcas
  • 1,007
  • 8
  • 11
-2

For example, Java Platform Standard Edition 7 Documentation has a link to download "JDK 7 Documentation" in the sidebar under "Downloads". I'd expect the same for other versions.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jakub Holý
  • 6,019
  • 3
  • 33
  • 33
-2

For the download of the latest Java documentation (jdk-8u77) API

Navigate to Java 19 and Java 17 available now.

Under Addition Resources and under Java SE 8 Documentation, Click the Download button.

Under Java SE Development Kit 8 Documentation* → *Java SE Development Kit 8u77 Documentation

Accept the License Agreement and click on the download ZIP file.

Unzip the downloaded file.

Start the API documentation from jdk-8u77-docs-all\docs\api\index.html.

For the other Java versions API download, follow the following steps.

Navigate to http://docs.oracle.com/javase/

From Release dropdown, select either of Java SE 7/6/5

On the corresponding Java SE page and under Downloads left side menu, click JDK 7/6/5 Documentation or Java SE Documentation.

Now on the next page, select the appropriate Java SE Development Kit 7uXX Documentation.

Accept the license agreement and click on Download ZIP file.

Unzip the file and start the API documentation from jdk-7uXX-docs-all\docs\api\index.html.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
vinsinraw
  • 2,003
  • 1
  • 16
  • 18
-2

The updated latest version of "The Java language Specification" can be found via the following links. Java 7

Java 8