Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

See Sun source code on Eclipse

Tags:

java

eclipse

How can I see Sun/Oracle code, in Java, on Eclipse? For instance, the source code of System.out.println.

like image 727
rnunes Avatar asked Feb 23 '23 22:02

rnunes


2 Answers

When you installed the JDK, did you opt to install the source as well? It's typically in src.zip. If you configure Eclipse to build against the JDK and specify the location of src.zip (if it's not detected automatically) you can just go into the JRE types like any other.

(Note that you can't easily see the exact code for System.out.println as it depends on the value of System.out at the time... but you can look at PrintWriter etc.)

like image 76
Jon Skeet Avatar answered Feb 25 '23 12:02

Jon Skeet


Tell Eclipse to use the JDK as the Java runtime inside Eclipse.

Preferences -> Java -> Installed JRE's -> Add, and then point to the JDK installation directory. Then check it to be the default used.

like image 27
Thorbjørn Ravn Andersen Avatar answered Feb 25 '23 12:02

Thorbjørn Ravn Andersen