Source code for Mac OS X Java Updates

JavaMacos

Java Problem Overview


Java for Mac OS X 10.6 Update 3 upgraded to java 1.6.0_22. However, they did not include the source code or JavaDoc. Does anyone know if Apple provides the source, and if so, where to find it?

I'd like to attach the source to Eclipse.

Java Solutions


Solution 1 - Java

I had the same problem today - I installed the Java Developer package from http://connect.apple.com, but couldn't find "src.jar" in /System/Library/Frameworks/JavaVM.framework/... anymore. On my machine, it's now in
/Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home/src.jar.

Update: For the latest version from March 2011, the jar is now:
/Library/Java/JavaVirtualMachines/1.6.0_24-b07-334.jdk/Contents/Home/src.jar

Once again, you'll have to download the new Java Developer package first.

Solution 2 - Java

What I do is as follows:

Download and install the Java Developer Kit (using your developer AppleId), current version 1.6.0_24-b07-334.jdk, and then in a shell, cd to the /System/Library/Frameworks/JavaVM.framework/Home directory.

Put in symbolic links to the jdk source files, src.jar, docs.jar and appledocs.jar, in the jdk you've just downloaded, that is:

sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_24-b07-334.jdk/Contents/Home/src.jar src.jar

and similarly for the other two jars.

Then, in Eclipse/Preferences, you can create a new Installed JRE by duplicating the existing one (the existing one points to something like /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home) and then select the new Installed JRE and remove the original.

The Eclipse Projects might need updating to point to the 'new' JRE, but the source and javadocs should now be available for the standard java stuff without further ado.

NB Ensure that the version of the jdk matches the version of your system Java for this to work properly.

Solution 3 - Java

Install java source, docs in 8 steps:

  1. Sign in with your Apple ID (http://connect.apple.com)

  2. Go to https://developer.apple.com/downloads/index.action

  3. Download Java for OS X 2012-00 Developer Package*

  4. Install javadeveloper_for_os_x_ * .dmg.

  5. Go to Eclipse > Preferences > Java > Installed JRE

  6. Click Search...

  7. Choose JRE with location like /Library/Java/JavaVirtualMachines/1.6.0_your_jdk_filename.jdk/contents/home. In my case jdk file name was 1.6.0_33-b03-424.jdk.

    You can find the file name of jdk in terminal: ls -l /Library/Java/JavaVirtualMachines

  8. Now, when you try "open declaration" and get message "Source Not Found" press button Attach source... and paste /Library/Java/JavaVirtualMachines/1.6.0_your_jdk_filename.jdk/contents/home/src.jar

Solution 4 - Java

These are the exact steps that worked for me.

Go to the apple dev java downloads page and get the latest one you can (the apple dev web site will not let you download packages that are unsuitable for your OS version).
I installed Java Developer Package for Mac OS X 10.6 Update 5 (Disk Image).

Then I executed these commands:

sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_26-b03-384.jdk/Contents/Home/src.jar /System/Library/Frameworks/JavaVM.framework/Home/src.jar
sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_26-b03-384.jdk/Contents/Home/docs.jar /System/Library/Frameworks/JavaVM.framework/Home/docs.jar
sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_26-b03-384.jdk/Contents/Home/appledocs.jar /System/Library/Frameworks/JavaVM.framework/Home/appledocs.jar

Then I restarted Eclipse (I didn't have to create a new JRE).

Solution 5 - Java

Solution 6 - Java

Found it also not working after download and installation. Using the directory didn't work either for me. This helped finally:

 sudo cp  /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home/src.jar /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/

and the linked it through eclipse!

Solution 7 - Java

I found that the solutions were not working for me (not sure what I am doing wrong), but I was able to see the source in Eclipse when I selected the directory of src.jar instead of specifying the actual jar.

Solution 8 - Java

FYI; On a Macbook Pro 2008, however reinstalled from scratch with Lion and NetBeans 7.0.1, thus the package Java 10.7 update 1 (the latest release), the source and JavaDoc were luckily auto installed after downloading the developer package as described in this thread. All is well.

Solution 9 - Java

On 31-Jan-2012, Apple posted the Java for Mac OS X Developer Preview 11M3614+10M3614 on their developer site.

This is a version that includes source code, doc, etc. (i.e., everything a developer needs).

Solution 10 - Java

For OSX 10.7 Lion running Java update 1, I found the sources to be in: /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/src.jar. As noted in the other answers, you will first need to download and install the Java Developer package from Apple before setting this directory in your IDE.

Solution 11 - Java

Download ubuntu package from the following link, extract it (usr ar command i.e. ar -x *.deb),

copy src.zip file and save it.

http://packages.ubuntu.com/hardy/all/sun-java6-source/download

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioncurthipsterView Question on Stackoverflow
Solution 1 - JavaChris LercherView Answer on Stackoverflow
Solution 2 - JavaSteve PowellView Answer on Stackoverflow
Solution 3 - JavaalexfvView Answer on Stackoverflow
Solution 4 - JavaBohemianView Answer on Stackoverflow
Solution 5 - JavaAdam VandenbergView Answer on Stackoverflow
Solution 6 - JavaoaeView Answer on Stackoverflow
Solution 7 - Javalindon foxView Answer on Stackoverflow
Solution 8 - JavacarlView Answer on Stackoverflow
Solution 9 - JavajadcView Answer on Stackoverflow
Solution 10 - Javapm_labsView Answer on Stackoverflow
Solution 11 - JavaSumit KapoorView Answer on Stackoverflow