JDK documentation in IntelliJ IDEA on Mac OS X

女生的网名这么多〃 提交于 2019-11-29 19:19:25
Chris Williams

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  
    

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

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

Yishai

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!