Go to the Package Explorer view with the file open in the current editor. Click the "Link with Editor" toggle (the two arrows). This should jump you to the class file you are viewing, which should be in the jar you are using. If the jar is in a library, you should see the path to the jar in the package explorer. If not you can see the path to it in the preferences. From there you can also use Chin Huang's answer to find where the given source file is.
Answer from ILMTitan on Stack OverflowGo to the Package Explorer view with the file open in the current editor. Click the "Link with Editor" toggle (the two arrows). This should jump you to the class file you are viewing, which should be in the jar you are using. If the jar is in a library, you should see the path to the jar in the package explorer. If not you can see the path to it in the preferences. From there you can also use Chin Huang's answer to find where the given source file is.
View the Properties for the JAR file. Under Java Source Attachment, you will see where Eclipse gets the source code for classes in the JAR file.
When you are coding in Eclipse, press CTRL and click on any core Java class name in your source. Eclipse will now show a screen saying you don't have the sources installed. However, in this screen there is a link saying "Attach source...". Click that link and import the src.zip file from your JDK installation directory (src.zip). This should do the trick
You need to have the JDK installed. Then you can look in JDK_INSTALL_DIR\src.zip
For me it is C:\Program Files\java\jdk1.6.0_11\ (depends on your current version)
You don't need to get a special open source version.
You need to attach source of the corresponding library.
Download Junit's source zip ( from their release site, corresponding to the JUNIT you are using) - example link
Then follow these steps in IBM's link on the topic - with steps
Once you do that, Ctrl + click on the class you interested in - while you are in the editor, you will see its source.
Multiple ways:
- download the sources and add them to the project build path
- use maven and set it to download sources
- use a decompiler - for example JD-Eclipse
If you have the jar added to a project's classpath, you can view its source by:
- Expanding
Referenced Librariesin thePackage Explorerview - Expand the jar you're looking at
- Double clicking on a .class file
You need both the .class and .java file in the jar to view source, though.
If you have only the .java file, the class won't appear at all.
If you have only the .class file, the class will appear as bytecode.
Example:

Extract the jar in some source directory (it's a zip file), and create a project with this directory as source.
Or, if this source jar file contains the sources of a classes jar file that is used as a library in your Eclipse project, just right-click on this jar file, select "Properties", then "Java Source Attachment", then "External File", and select the source jar file. Then each time you browse a class from this classes jar file, Eclipse will automatically show you its source code.
For taking a look into classes which come without source files (e.g. 3rd party JARs), I use a Java decompiler: JadClipse
This one nicely integrated into Eclipse. Code looks strange sometimes, yet good enough for a rough estimation of what happens behind closed doors. Note that vendors might prohibit decompiling their code, IANAL.
I've successfully and effortlessly being able to do what you ask using JD plugin for eclipse: http://jd.benow.ca/
It gets installed in less than 5 minutes and it's really smooth and flawless.
In order to see the source codes of JDK in eclipse you should add JDK path instead of JRE to your workspace or for a specific project SDK. I assume you are a developer and you've installed JDK on your system.
To do that:
- Right click and select Properties (or press Alt+Enter) on your project.
- From the left tree styled menu select Java Build Path
- On the right select the Libraries
- Select the JRE System Library

- From the right side buttons click on edit, and edit the path from
JRElocation to points to theJDKlocation in your file system.



- Then click on Finish and the OK buttons of all opened dialogs to save the configurations and you set to go.
Hope this would be helpful.
you have to add Eclipse Plugin from
HELP -> Eclipse Marketplace
I personally used
Enhanced Class Decompiler
just install it. and have fun.
You can attach source code to libraries. yourProject / Properties / Java Build Path / Libraries / yourLibrary / Source attachment, and then enter the folder or zip file containing the source code (which you need to download separately).
If you only have the object code (.class files), then you need to learn to read ByteCode (which Eclipse shows pretty nicely) or use a Java ByteCode disassembler.
As in android sdk what we get is a compiled jar file which contains all the classes. So in eclipse you can't read the source, but you may use, The official online version to read the source code of classes:
http://developer.android.com/reference/packages.html
[In eclipse although by CTRL+Click on import may show you a bit about the class, although that won't be easy to understand :)]