How do I add an SDK under Mac OSX so that it finds JavaDoc and Source?

I know that under MacOSX the various installed JDKs are located under:

/System/Library/Frameworks/JavaVM.framework/Versions

When I add an SDK to Intellij, specifiying the appropriate JSDK home path, Intellij finds the classpaths of all the various jars. That works fine.

But it does not locate any sourcepath or documentation paths.

This means that basic Intellij operations like Shift F1 to find JavaDoc are not available - which is annoying.

Also, I can't navigate to the source code of the underlying Java library classes (like String) - also annoying.

Do I really need to separately download JavaDoc and Source jars from somewhere else and manually point Intellij to them? Or is there a smarter way to automatically get this basic Java JDK support for standard documentation and library source code?

4 comments
Comment actions Permalink

The source and docs where moved under Snow Leopard:


/Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home:45> ls -l
total 218792
-rw-rw-r--   1 root  admin    340760 Oct 12 00:40 appledocs.jar
drwxrwxr-x  41 root  admin      1394 Dec  7 09:49 bin
lrwxr-xr-x   1 root  admin         3 Dec  7 09:49 bundle -> ../
-rw-rw-r--   1 root  admin  38865107 Oct 12 00:39 docs.jar
lrwxr-xr-x   1 root  admin        10 Dec  7 09:49 include -> ../Headers
drwxrwxr-x  42 root  admin      1428 Dec  7 09:49 lib
drwxrwxr-x  41 root  admin      1394 Oct 12 00:37 man
-rw-rw-r--   1 root  admin  72799185 Oct 12 00:38 src.jar


However, please note you do have to download another package from Apple to get these files.

1) Goto http://connect.apple.com
2) On the right side you will see a download section, choose Java
3) Downloadt the appropriate download for your OS
4) Install

This may be a direct link to the Java downloads section, not sure if direct linking works, but you can give it a try:

http://connect.apple.com/cgi-bin/WebObjects/MemberSite.woa/wo/5.1.17.2.1.3.3.1.0.1.1.0.3.9.3.3.1

Then you can add them to your SDK settings:

Screen shot 2011-03-29 at 9.57.34 AM.PNG

0
Comment actions Permalink

Thankyou - that is exactly what I was looking for.

And it is not exactly obvious!

This is something where I think that Intellij could help us by encapsulating that knowledge about the peculiarities of the way Mac installs Java - and automatically locating the currently installed SDK's and picking up the doc and source from wherever Apple has dumped them.

At the very least, Intellij could document this as you have so kindly done.

Many thanks.

John

0
Comment actions Permalink

This would make a great subject for a knowledge base article. It would also have been helpful if Apple had documented that change of locations (I couldn't find it in anything associated with the Java release for Snow Leopard, but it was there and I just couldn't find it)

0
Comment actions Permalink

This would make a great subject for a knowledge base article. It would also have been helpful if Apple had documented that change of locations (I couldn't find it in anything associated with the Java release for Snow Leopard, but maybe it was there and I just couldn't find it)

0

Please sign in to leave a comment.