I think my JDK is broken. I am on OS X 10.6.8.
I want to look in the sources when debugging in Eclipse, etc, but Eclipse can't find the sources, so I looked up the installed JREs and found this path with the title JVM 1.6.0 (MacOS X Default)
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
In Terminal I went to the directory /System/Library/Frameworks/JavaVM.framework/Versions
and executed ls -al
:
drwxr-xr-x 13 root wheel 442 8 Sep 22:46 .
drwxr-xr-x 12 root wheel 408 8 Sep 22:46 ..
lrwxr-xr-x 1 root wheel 5 8 Sep 22:45 1.3 -> 1.3.1
drwxr-xr-x 3 root wheel 102 21 Jul 2009 1.3.1
lrwxr-xr-x 1 root wheel 10 8 Sep 22:45 1.4 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 8 Sep 22:45 1.4.2 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 8 Sep 22:45 1.5 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 8 Sep 22:45 1.5.0 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 8 Sep 22:45 1.6 -> CurrentJDK
lrwxr-xr-x 1 root wheel 10 8 Sep 22:45 1.6.0 -> CurrentJDK
drwxr-xr-x 10 root wheel 340 8 Sep 22:46 A
lrwxr-xr-x 1 root wheel 1 8 Sep 22:45 Current -> A
lrwxr-xr-x 1 root wheel 59 8 Sep 22:45 CurrentJDK -> /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents
So Eclipse already has the proper JDK linked. Another test:
$ javac -version
javac 1.6.0_26
$ which javac
/usr/bin/javac
$ ls -al /usr/bin/ | grep javac
lrwxr-xr-x 1 root wheel 75 8 Sep 22:45 javac -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javac
So it all looks fine, but there is no rt.jar or src.jar Here is a screenshot:
So I try to reinstall it. I go to Apple's website and download this package: Java for Mac OS X 10.6 Update 5 Developer Package
, file: javadeveloper_for_mac_os_x_10.6__10m3425.dmg
.
The installation finished successfully, but it doesn't change anything.
I show the last modified files on my computer, these are only some java tools, located in usr/share/java/Tools
There still is no rt.jar or src.jar in the java home directory.
NOTE: This answer is old and for Apple Java 6. For Oracle Java you need to download the JDK as it includes src.zip.
The source is not included in the default Java download. You need to additionally install the corresponding development package available from ADC.
In addition, Eclipse has not yet been taught how to find the src.zip file and the dialogue cannot look inside packages.
On my 10.7, the above mentioned installation put src.zip in /Library/Java/JavaVirtualMachines/1.6.0_26-b03-383.jdk/Contents/Home/src.jar
From: http://lookfirst.com/2011/03/fix-missing-source-for-java-mac-os-x.html (adapt version #s and paths as needed)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With