See Sun Source Code on Eclipse

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

+4
source share
4 answers

When you installed the JDK, did you also decide to install the source? This is usually in src.zip. If you configure Eclipse to build against the JDK and specify the location of src.zip (if it is not automatically detected), you can simply switch to JRE types just like any other.

(Note that you cannot easily see the exact code for System.out.println , since it depends on the value of System.out at that time ... but you can see PrintWriter , etc.)

+5
source

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

Settings -> Java -> Installed JRE -> Add, and then specify the JDK installation directory. Then check if it is used by default.

+3
source

To connect JDK sources to a JRE that uses Eclipse:

Go to the window, the settings, Java installed by the JRE, click on the JRE that you are using, click the "Change" button. Then select the rt.jar file (Java runtime library) and click the "Original rt.jar " button. Enter the location of the src.zip file, which should be located in the JDK installation directory.

+1
source

Sun / Oracle source code directly from eclipse is not possible. If it were your own code, you could right-click on the method, say println() and click on "Open declaration", and eclipse will show you where the method was declared. However, Eclipse does not bind source code to it, so it will not work with Sun / Oracle code.

-1
source

All Articles