13

After updating to the latest (and now deprecated, sniff...) update of Apple's JDK, Eclipse does not show the source code for JDK classes anymore. It asks me to attach the source location file or folder. Where can I find that?

Petter Friberg
  • 21,252
  • 9
  • 60
  • 109
Thilo
  • 257,207
  • 101
  • 511
  • 656

5 Answers5

15

It seems that Java for Mac OS X 10.6 Update 3 does not include the sources anymore. There is a separate package "Java for Mac OS X 10.6 Update 3 Developer Package" now. See http://lookfirst.com/2010/10/how-to-fix-missing-source-for-latest.html

michid
  • 10,536
  • 3
  • 32
  • 59
6

For each update from Apple, I write a new blog post with the updated symlinks. I noticed a lot of traffic on my blog from one of the answers, so I figured I might as well update things with the latest release.

I could write a simple shell script to do this for you, but that would require you to download a file. Seems simpler to just execute a few easy commands.

This is the latest one for update 5:

http://lookfirst.com/2011/06/fix-missing-source-for-java-mac-os-x.html

Public Profile
  • 1,817
  • 1
  • 21
  • 20
  • Thanks. Another good thing related to this would be to find proper release notes about what has changed. The tech note from Apple is completely non-informative. – Thilo Jul 06 '11 at 08:18
  • Good luck with that. Apple is rarely very informative with that information. – Public Profile Jul 06 '11 at 22:32
3

I am using Mac OS 10.8.5. I downloaded the java for Mac OS 10.7 and installed it. I found the src.jar file in

/Library/Java/JavaVirtualMachines/1.6.0_37-b06-434.jdk/Contents/Home/src.jar.

Then I

  1. Opened eclipse(JUNO)
  2. Eclipse > Prefereces > JAVA > Installed jre
  3. Edit the java listed

In the jre system libraries section,

  1. Expand the first one (i.e., classes.jar)
  2. You can see that src is not attached
  3. Double click that and provide the above location

That's it.

Garrett Hyde
  • 5,409
  • 8
  • 49
  • 55
suraj
  • 31
  • 1
1

In my case the sources are in

/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/src.jar

You might need to set this in the Eclipse preferences: Java - installed JREs. Select the 1.6 JVM and click edit. Now select classes.jar from the list of JRE system libraries, click source attachment and enter the path to your src.jar.

michid
  • 10,536
  • 3
  • 32
  • 59
  • I don't have src.jar. What OS version are you using, and did you run the latest Java software update? Did that take src.jar away? I definitely had sources attached in Eclipse before (and by default, I think). – Thilo Nov 03 '10 at 01:15
  • I'm on OSX 10.6.4 and I did not run the latest Java update. That is I'm on java version "1.6.0_20". It might well be that the update takes src.jar away. An earlier update uninstalled java 1.5 and some of my Maven versions. – michid Nov 03 '10 at 10:06
  • 1
    Every JRE update does take src.jar away. When I updated to 1.6.0_26 from 1.6.0_24 I had to got to developer.apple.com/downloads and download the JDK again to get the source. – David G Oct 26 '11 at 18:00
0

To all the guys who's been suffering from searching the source code here and there for hours but finally get nothing.

For Eclipse to attach(imperfectly available for 1.6): jdk1.7.0_21_src_for_mac.zip

Anderson
  • 2,496
  • 1
  • 27
  • 41