jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Sources of the java standard library? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Sources of the java standard library?" Watch "Sources of the java standard library?" New topic

Sources of the java standard library?

Andreas Svenkson
Ranch Hand

Joined: Jan 17, 2011
Posts: 179
Hey guys.

I was wondering, I am sure I have sometimes (by accident) in netbeans opened the source-file of a class I was using in my program (say, for example, Integer), and I was wondering how to do this in Eclipse.

I was also wondering, are all source-files of the entire java SE api included in the jdk installation? Where in the installation can I find them?

Ninad Kulkarni
Ranch Hand

Joined: Aug 31, 2007
Posts: 802

Try in following path after jdk installation


SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
Rob Spoor

Joined: Oct 27, 2005
Posts: 20271

It's actually a file called src.zip inside the JDK's root folder.

As for how to do this in Eclipse, you need to edit the JAR file, either from the installed JRE section or from the project's library list.

Installed JRE:
- Window -> Preferences
- Java -> Installed JREs
- select the JRE and click Edit
- select rt.jar and click Source Attachment
- select External File and browse for the src.zip file

Project library:
- right click the project and click Properties
- select Java Build Path
- select the Libraries tab
- expand your library (with the +), select Source Attachment and click Edit

How To Ask Questions How To Answer Questions
Andreas Svenkson
Ranch Hand

Joined: Jan 17, 2011
Posts: 179
Excellent, thanks Rob.

Out of curiousity, why is it specifically the rt.jar file that I should add the src.zip file to? What about all the other libraries listed under the jre?

// Andreas
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15082

rt.jar contains the runtime classes of the Java API; these are all the classes and interfaces listed in the API documentation. The other jars contain non-public implementation classes that you shouldn't be using directly in your program.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link: http://aspose.com/file-tools
subject: Sources of the java standard library?
It's not a secret anymore!