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,322
  • 27
  • 84
  • 93
Varun Vats
  • 489
  • 1
  • 4
  • 14

4 Answers4

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

Rafael Oltra
  • 1,239
  • 9
  • 15
  • 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. – Varun Vats Jul 07 '13 at 02:43
  • 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 – Rafael Oltra Jul 07 '13 at 04:06
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

  • 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? – aalazz Feb 06 '19 at 18:49
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.

Varun Vats
  • 489
  • 1
  • 4
  • 14
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.

Community
  • 1
  • 1
Chip McCormick
  • 744
  • 4
  • 17