Java/Eclipse on MacOSX: where is the src.zip?
Asked Answered
L

13

48

With the latest Java update on MacOSX 10.6, Eclipse does not find the Java sources anymore.

I am not exactly sure (i.e. don't remember anymore) if I have downloaded the sources manually in the past and put them somewhere or if MacOSX provided them and Eclipse found them automatically.

Does MacOSX have the sources somewhere? (Please no assumptions here. I really want to know that.)

If not, where can I get them?

Limiter answered 24/10, 2010 at 23:26 Comment(3)
did you install the jdk or the jre? the jdk has the source code as far as I can tell but not the jre on it's ownProteus
@hhafez: I have not installed anything. It is preinstalled by MacOSX. But it must be the JDK because I am able to compile things.Limiter
The hack-of-least-resistance on my snow leopard macbook was to change the default JRE from "Java SE 6 (MacOS X Default)" to just "Java SE 6". "Java SE 6" has its location at /Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home which has a src.jar. "Java SE 6 (MacOS X Default)" has its location at /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home which does not have src.jar. I am hopeful that software updates to Java 6 keeps this fresh.Leralerch
G
31

After installing the most recent Java update you'll find src.jar under

/Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home

That's where I pointed "JRE home" for Java 1.6 in Eclipse to. Everything works as expected (until now :)

Gossipy answered 25/10, 2010 at 12:33 Comment(6)
What... :P Have I really always overlooked this? I think I always have looked at the JDK which is installed in /System/Library/.... I didn't knew there was also another JDK in /Library/....Limiter
I don't have /Library/Java/JavaVirtualMachines - I think that must be something Sebastian put in himself.Insignificance
@Mike Baranczak: You should have /Library/Java/Home/src.jar. The newer one in JavaVirtualMachines is a developer release.Chrismatory
+1 Thanks! I added some related NetBeans findings in an adjacent answer.Chrismatory
I don't have /Library/Java/Home/src.jar or /Library/Java/JavaVirtualMachines/1.*. I have /Syste,/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home, but no src.jar in there. Why is this so hard on a Mac?Durango
This is not the case, at least with "Java for Mac OS X 10.6 Update 17". If I update that from support.apple.com/kb/DL1573, I the Home directory does not include any src.jar.Arsenide
B
43

As I understand it, as of "Java for Mac OS X 10.6 Update 3", there are 3 places you will find Java installed on MacOS.

  • /System/Library/Frameworks/JavaVM.framework/ was the old place.
  • /System/Library/Java/JavaVirtualMachines/ is the new standard place - there you will find the new release.
  • /Library/Java/JavaVirtualMachines is for '...developer previews, and 3rd party JVMs'

Note the MacOS rule of putting Apple-supplied standard components in /System/Library and local extensions into /Library

The JDK installed by default does not now have a src.jar (although it is a JDK, so has javac etc). But if you install the 'Java Developer package' from Apple, you will get

/Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk

which has src.jar under Contents/Home

So I think that the sane thing to do is install the developer package and point to it from your IDE.


Update - for "Java for Mac OS X 10.7 Update 1", having installed the developer package the source can be found at

/Library/Java/JavaVirtualMachines/1.6.0_29-b11-402.jdk/Contents/Home/src.jar

Bluh answered 16/11, 2010 at 11:54 Comment(2)
developer.apple.com/library/mac/#releasenotes/Java/…Jenjena
This should be the answer to this question, particularly the link "from Apple" pointing to: developer.apple.com/downloads/index.action#Latrice
G
31

After installing the most recent Java update you'll find src.jar under

/Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home

That's where I pointed "JRE home" for Java 1.6 in Eclipse to. Everything works as expected (until now :)

Gossipy answered 25/10, 2010 at 12:33 Comment(6)
What... :P Have I really always overlooked this? I think I always have looked at the JDK which is installed in /System/Library/.... I didn't knew there was also another JDK in /Library/....Limiter
I don't have /Library/Java/JavaVirtualMachines - I think that must be something Sebastian put in himself.Insignificance
@Mike Baranczak: You should have /Library/Java/Home/src.jar. The newer one in JavaVirtualMachines is a developer release.Chrismatory
+1 Thanks! I added some related NetBeans findings in an adjacent answer.Chrismatory
I don't have /Library/Java/Home/src.jar or /Library/Java/JavaVirtualMachines/1.*. I have /Syste,/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home, but no src.jar in there. Why is this so hard on a Mac?Durango
This is not the case, at least with "Java for Mac OS X 10.6 Update 17". If I update that from support.apple.com/kb/DL1573, I the Home directory does not include any src.jar.Arsenide
P
7

This is my experience with src.jar !.

  • As mentioned earlier, you will have to sign up for the Apple developer account.(its free)

  • go to Downloads for Apple developers and then search for java.

  • I have chosen "Java for OS X 2013-005 Developer Package"
  • Once you download and install the package, you will find src.jar at /Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/Home/

    Hope this helps!

Parkland answered 22/9, 2011 at 4:28 Comment(1)
Just wanted to confirm that this is the way to go. The pic is outdated though, but process and paths are correct.Magallanes
S
4

It appears in the latest OSX 10.6.7 (java 1.6.0_24) they have cleaned up all those directories... no src.jar exists anywhere and most of the indicated directories are missing.

annoying to no end...

Superphysical answered 17/6, 2011 at 2:26 Comment(1)
I think I found it in: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/** I think I had to go through the update process to get it to show up though.Superphysical
O
3

as of today, 6/1/12, the Java Devloper Package for OSX 10.7, no longer come with src.jar under Home directory. Some google results pointing to Apple's decision in 2010 to deprecate Java support in OSX (the ported one by Apple). And Oracle start providing Mac OS X JDK since this April. So going forward, install JDK from Oracle.

Ostap answered 1/6, 2012 at 16:40 Comment(0)
M
3

With Oracle Java SE 7 for Mac OS X x64 the src.zip ends up in the following location, in this case the particular version is Java SE 7u10

/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home/src.zip
Manumission answered 20/12, 2012 at 19:26 Comment(0)
C
2

On Mac OS X 10.5.8, after updating to Java 1.6.0_22 and installing the most recent developer update dated 20-Oct-2010, src.jar for Java 6 is not present.

$ find /System/Library/Java /System/Library/Frameworks -name src.jar
/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home/src.jar
/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home/src.jar

Navigating to source in NetBeans 6.9.1 says compiled code for all constructors and methods, e.g. java.awt.Point:

public Point() {
    //compiled code
    throw new RuntimeException("Compiled Code");
}

It may be possible to extract a usable JAR from a previous update, as suggested in this thread.

Addendum: On NetBeans, the default platform's location is an attribute in the file ~/.netbeans/6.9/config/Services/Platforms/org-netbeans-api-java-Platform/default_platform.xml:

<sources>
    <resource>jar:file:/Library/Java/JavaVirtualMachines/
        1.6.0_22-b04-307.jdk/Contents/Home/src.jar!/src/
    </resource>
</sources>

Alternatively, the file /Library/Java/Home/src.jar may be referenced:

<sources>
    <resource>jar:file:/Library/Java/Home/src.jar!/src/</resource>
</sources>
Chrismatory answered 25/10, 2010 at 3:11 Comment(0)
B
2

Call me old fashioned, but:

find /Library/Java/JavaVirtualMachines/ -name src.jar

worked for me :-)

Bullwhip answered 7/8, 2014 at 13:15 Comment(1)
Or better yet find /Library/Java -name "src.*" Since it may be a .zip (was in my case)Shoemaker
F
1

Maybe this explains it: ?

As of the release of Java for Mac OS X 10.6 Update 3, the Java runtime ported by Apple and that ships with Mac OS X is deprecated. Developers should not rely on the Apple-supplied Java runtime being present in future versions of Mac OS X Java for Mac OS X 10.6 Update 3 and 10.5 Update 8 Release Notes

Foreigner answered 15/11, 2010 at 20:51 Comment(0)
W
1

If you want Eclipse to always point to the current default JDK and its sources point it to:

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

Eclipse will then resolve the symbolic link CurrentJDK and point it to the current JDK.

Watercool answered 24/4, 2011 at 17:0 Comment(0)
P
0

Thanks to folks that have previously provided answers; they've been helpful.

As a newb to Mac (10.6.6), here's what I did for MyEclipse, which should also work for Eclipse; I've not tested this in a disconnected mode. When trying to add another JRE for MyEclipse 8.5, it required a "MacOS X VM", and would not support a "Standard VM". I tried modifying both the eclipse.ini and myeclipse.ini files, and also tried starting MyEclipse from the command line with a specific JAVA_HOME set with no avail.

1) download and install the correct Java Developer Package. Go to System Preferences -> Software Update -> Installed Software. You may have multiple versions of a given installation, in my case, I had both "Java for Mac OS X 10.6 Update 2" and "Java for Mac OS X 10.6 Update 3" - so be sure to sort by name, or verify some other way. As of today, the downloaded file name was javadeveloper_10.6_10m3261.dmg.

2) In a terminal window, I added some symlinks from the OS VM that point to jars in the Standard VM. I have slightly modified security permissions, so you may or may not need to use sudo to create the symlinks.

cd /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home/appledocs.jar
sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home/docs.jar
sudo ln -s /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home/src.jar
Pedestrianism answered 16/1, 2011 at 17:42 Comment(0)
L
0

if nothing is working just download the sources from http://jdk7src.sourceforge.net/ here and add them. worked for me.

Listerism answered 8/2, 2015 at 3:27 Comment(0)
A
0

Just found the src.zip on my mac at /Library/Java/JavaVirtualMachine/adoptopenjdk-11.jdk/Contents/Home/lib/src.zip

Adding to 'project structure - SDKs - Sourcepath' allowed me to view java source files in IntelliJ...

Annabal answered 23/3, 2020 at 16:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.