Hristo
Hristo

Reputation: 46477

installing Java source code on OS X 10.9 Mavericks

I installed Java on my new laptop running OS X 10.9 Mavericks (downloaded from http://support.apple.com/kb/DL1572?viewlocale=en_US)...

$ java -version
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

However, when I start Eclipse, I can't view the Java source code. Where/How can I get the Java source code installed on my machine so that I can view it through Eclipse?

Upvotes: 4

Views: 2019

Answers (4)

ctrueden
ctrueden

Reputation: 6992

Assuming you do actually need to use Java 1.6 for some reason, Apple does provide the source code to the Apple versions of Java:

  • Visit Apple Developer Downloads.
  • Log in with your Apple developer ID.
  • In the search box, type "java for os x"
  • Download the latest Java for OS X Developer Package (at the time of this writing, it is "Java for OS X 2013-005 Developer Package").

As part of the installation, it provides a src.jar that you can attach in /Library/Java/JavaVirtualMachines/1.6.0_65-b14-462.jdk/Contents/Home.

Upvotes: 2

matsev
matsev

Reputation: 33759

I suggest that you download and install the latest JDK 7 version from Oracle. On Mountain Lion, the source code is available in the /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/src.zip after the installation (if you have installed JDK 7u45).

Upvotes: 0

Sven Painer
Sven Painer

Reputation: 194

I think you only installed a Java Runtime Environment (JRE). To see the Java source code you need a Java Development kit (JDK). Oracle gives you the ability to downlad the JDK also for Mac OS X, so you should consider using this. Then you find a file src.zip inside the directory of the JDK and this will contain the source code.

Upvotes: 1

Sotirios Delimanolis
Sotirios Delimanolis

Reputation: 279960

On Eclipse, go to Navigate, select Open Type, type in some JDK class, like [java.lang.]String and click OK. There should be a Attach Sources button that lets you select the source files. Navigate to your Java JDK installation and select the src.zip file that should be included.

Upvotes: 1

Related Questions