0

I like the way you can browse the source code of a library in GrepCode. Is there any way I can do the same in Eclipse?

I know that I can open the declaration of a class and look through it, but there seems to be no way I can search for something (a method, for example) in the Declaration window.

What I am really looking for is a way to browse the source code of the standard library just like I browse the source code of a class I am writing. It doesn't necessarily have to be the source that ships along with my JDK; I am happy to look at some other version as well.

What would be the best way to achieve this? Will I have to download OpenJDK and add it as a project in Eclipse?

Paul Roub
36.5k27 gold badges88 silver badges95 bronze badges
asked Jul 4, 2013 at 0:32

4 Answers 4

1

You can install Java Decompiler plugin for Eclipse, such as JD-Eclipse

You could also use the src.zip file that ships alongside Oracle's JDK (located for example at something similar to C:\Program Files\Java\jdk{version} in Windows) and load it on Eclipse build path as a library (src.zip contains sources files for the java., javax. and some org.* packages, but not for com.sun.* packages)

Or you could download the whole bundle of source code for JDK at http://download.java.net/openjdk/jdk6/ (for JDK 1.6) and do the same

answered Jul 4, 2013 at 0:53
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for the suggestion to look at JD-Eclipse. For now I just went with the Search feature in Eclipse which fits my needs.
The search feature by itself will not show JDK Source Code, you have to load the source code as I mentioned or use a decompiler plugin
1

I think one of the good alternative for what you are looking for is zGrepCode. It allows you to browse Java Open Source projects as you are doing it in Eclipse by providing interlinking.

http://zgrepcode.com

Here is the place I found about this wonderful free tool.

https://dzone.com/articles/grepcode-is-down-whats-next?fromrel=true

answered Feb 6, 2019 at 18:16

1 Comment

While I agree zGrepCode is a good alternative to GrepCode, I think the question is specifically about browsing code directly in Eclipse. As far as I understand, this is not possible with zGrepCode. Am I missing something?
0

Actually I just went with the Search feature in Eclipse. Since I wanted to look at the source code for classes in the JRE libraries, I just do Search --> Java and select the appropriate options (see the attached screenshot).

enter image description here

I would think that this Search feature could also be used to search in the libraries included in your build path too.

answered Jul 4, 2013 at 3:24

Comments

0

Pretty sure that m2eclipse allows source browsing, see: Get source jar files attached to Eclipse for Maven-managed dependencies

Intellij also has a maven plugin available that allows browsing.

answered Aug 6, 2015 at 0:47

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.