I cannot for the life of me attach the java source code to eclipse so I can see the inner workings of the language. Not even something as simple as the String Class.
Old question, be here's what I ended up using Java Source Attatcher plugin: http://marketplace.eclipse.org/content/java-source-attacher#.U85j4rF-N7s
It can provide source for different opensource projects. One weird thing thou, if you have libraries under libs folder, you cannot attach from there, but you need to attach source clicking on jar displayed under "Libraries from external".
You need to attach java sources which comes with JDK(C:\Program Files\Java\jdk1.8.0_71\src.zip).
Steps(**Source: link):
Normally, if you have installed the JDK6u14, eclipse should detect it and declare it automatically in its "installed JRE" list.
If not, you can add that JDK through "Windows/Preferences": Java > Installed JREs
:
Just point to the root directory of your JDK installation: it should include the sources of the JDK (src.zip
), automatically detected and attached to rt.jar
by eclipse.
Hold ctrl key and then click on class of which you want to see the inner working (for ex: String
) then you will find there button "Attach Source". Click on it. Then click on External Folder. Then browse to your jdk location, per instance C:\Program Files\Java\jdk1.6.0
. That's it.
The easiest way to do this, is to install a JDK and tell Eclipse to use it as the default JRE. Use the default install.
(from memory)
Open Window -> Prefences. Select Installed Java runtimes, and choose Add. Navigate to root of your JDK (\Programs...\Java) and click Ok. Then select it to be the default JRE (checkmark).
After a workspace rebuild, you should have source attached to all JRE classes.
Answer For Eclipse 2019 With ScreenShots
rt.jar
from JRE systems library, click on corresponding drop down to expandSource attachment none
, Click on Source Attachment
Button, Source attachment configuration window will appear, Select external location
src.zip
file from jdk folder, say ok ok finish