How to attach source in eclipse for Jars, debugging and code look-up – JDK Example

Attaching source of any Jar in Eclipse e.g. JDK or open source libraries like Spring framework is a good idea because it help during debugging and code development. As a Java programmer at least you should attach the source of JDK in Eclipse IDE to find out more about JDK classes. Though Eclipse IDE is pretty good on code assist, sometimes You want to know what's going inside a library or a JDK method, rather than just reading the documentation. Interview questions like How HashMap works in Java or How substring cause memory leak can only be answered if you are familiar with the source code of these classes.  Once you attach source code of Java or Spring in Eclipse IDE, You can check code with just a single click. Some one may argue for Java decompiler like JAD which can create source from the .class file which is also a smart way to look code for open source library, but decompiled source file is not same as the original source file, as you lost comment and readability. As per my experience attaching source code corresponding to JAR file is much better than decompiling a class file using JAD decompiler. 
Read more »