Attach JDK source code with Eclipse

by Santosh K Saha | Category Core Java


Sometimes it is helpful for programmer to see source code of core java class while developing an application. In eclise to see source code, press "ctrl + any class name", this will take you to the source file of that class. Sometimes eclipse does not show the core java class source code by default, in this case you have to attach the jdk source code in eclipse.



There are different ways, you can attach JDK source code with eclipse.



1. Click Attach Source > External Location > External File. Select "src.zip" file located in your root directory of the installed JDK mostly in "C:/Program Files/Java/jdk1.8.0_101/src.zip"


2. Select Window > Preference > Java > Installed JREs > jre1.8.0_101 > rt.jar > Source Attachment(none) > External Location > External File. Select "src.zip" file located in your root directory of the installed JDK mostly in "C:/Program Files/Java/jdk1.8.0_101/src.zip"


3. Select Project > Properties > Java Build Path > Libraries > rt.jar > Source Attachment(none) > External Location > External File. Select "src.zip" file located in your root directory of the installed JDK mostly in "C:/Program Files/Java/jdk1.8.0_101/src.zip"

Note: Like our facebook page to get updated of free classes and tutorials.