• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sources of the java standard library?

 
Andreas Svenkson
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?

Thanks,
Andreas.
 
Ninad Kulkarni
Ranch Hand
Posts: 802
Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try in following path after jdk installation

Java\jdk1.6.0_17\src
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Andreas Svenkson
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15495
43
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic