66

I'd like to know how to setup IntelliJ to point to the JDK documentation so the documentation popups that display during code completion will show me what the function I'm looking at is going to do. For some reason IntelliJ isn't able to find the JavaDocs by default.

I'm also not 100% sure that the documentation is installed with the JDK that's installed with the OS. I don't see them in /System/Library/Frameworks/JavaVM.framework/ but I may be looking in the wrong place. If it's not included, I'd also like to know what needs to be downloaded and where it needs to be installed to get the JavaDocs for the JDK to show up in IntelliJ.

Chris Williams
  • 11,647
  • 15
  • 60
  • 97

4 Answers4

111

I had to combine the responses I got to this point and add a few extra details so I'm answering my own question.

  1. Search for "Java developer" from Downloads for Apple Developers
  2. Download and install "Java for Mac OS X 10.6 Update 9 Developer Package" (or later).
  3. In IntelliJ, open File -> Project Structure.
  4. Click on "SDKs" under "Platform Settings".
  5. Add the following paths under the "Documentation Paths" tab (the paths may be different based on which JDK you're using):

    /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/docs.jar!/docs/api  
    /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/appledocs.jar!/appledoc/api
    
  6. Add the following path under the Sourcepath tab:

    /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/src.jar!/src
    

Thanks, @Yishai for the download location and @Gareth Davis for the location of the documentation after installing.

Update for 10.7/10.8 [Mountain] Lion:

Steps are the same except for these changes:

  1. In step 2, download "Java for OS X 2012-005 Developer Package" (or later).

  2. Use these paths instead in step 5.

    /Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home/docs.jar!/docs/api  
    /Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home/appledocs.jar!/appledoc/api
    
  3. Use these paths instead in step 7.

    /Library/Java/JavaVirtualMachines/1.6.0_35-b10-428.jdk/Contents/Home/src.jar!/src  
    
nelsonjchen
  • 365
  • 6
  • 16
Chris Williams
  • 11,647
  • 15
  • 60
  • 97
  • If you want to navigate to the jars src.jar, appledoc.jar, docs.jar from Finder, Right click/Show package contents when you get to the JDK. Then drill down through Contents -> Home – JGFMK Dec 11 '10 at 19:43
  • When I gave this a try I noticed all the permissions got screwed up on my Hard Drive. I think it's a case of execute permissions not being set. But most of the things were for symbolic links. The Disk Utility says Repair Disk Permissions says it fixes them but it never does.. See http://discussions.apple.com/thread.jspa?messageID=12626162 and http://www.chriswrites.com/2009/04/17-reasons-why-your-mac-is-so-unbelievably-slow/ – JGFMK Dec 12 '10 at 21:42
  • 1
    What happens when there is a JDK 6 update? Do you have to re-download the docs? – Arne Evertsson Mar 25 '11 at 09:06
  • Awesome thank you. I have been searching for this for a long time..... +1 for such an detailed instruction. – uncaught_exceptions Sep 21 '11 at 20:46
  • Does Oracle no longer provide docs as part of a JDK 1.8 installation for the Mac? – Jim L. Jan 29 '15 at 02:29
  • One should notice that Apples "available for everybody" JDK (which they refer to on their support pages: http://support.apple.com/kb/DL1572) seems to not include the docs. Just the one for Apple developers does. – Florian Loch Feb 22 '15 at 11:02
39

Quick (and dirty?) solution: Point IntelliJ to http://download.oracle.com/javase/6/docs/api/

Arne Evertsson
  • 19,693
  • 20
  • 69
  • 84
  • 4
    +1 this is about the simplest most straightforward solution to this. Go to File -> Project Structure -> SDKs -> Apple 1.x -> DocumentationPaths, and the click specify URL. – whaley Mar 26 '11 at 18:14
4

have you installed the Apple Java Developer package?

It provides src.jar and docs.jar in /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home

Note this is since update 3. If these are present Intellij will just find them, or at least mine did.

details are in the Java update release notes

Gareth Davis
  • 27,701
  • 12
  • 73
  • 106
  • +1 The other day I suddenly had sources not linked in IDEA and had to install this and add it as a new JVM in IDEA and switch projects to use that JVM. That worked for me as well. – ColinD Nov 10 '10 at 15:52
  • I've just been rebuilding my Mac and I can confirm it used to do this, but you no longer get that with a reformat & reinstall/software updates approach any more. – JGFMK Dec 11 '10 at 19:08
  • I can also confirm it doesn't come as part of the Apple Developer tool suite any more either Xcode/Dashcode etc. The Developer download combined response is what I'm giving a try. – JGFMK Dec 11 '10 at 19:12
2

This should tell you what you need to know: Get local copies of Mac OS X Java source code and Javadoc – Concord Consortium wiki.

That page recommends going to https://connect.apple.com and downloading and installing “Java for Mac OS X 10.5 Update 2 Developer Documentation (Disk Image)” or the equivalent newer release. It describes a few ways to view the documentation, based on the Java jar file being located at a path like this:

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/src.jar
Rory O'Kane
  • 29,210
  • 11
  • 96
  • 131
Yishai
  • 90,445
  • 31
  • 189
  • 263