v0ld3m0rt
v0ld3m0rt

Reputation: 904

How to see the source code for java SDK (java.lang, java.util, ...) classes in Eclipse?

I want to read jar class files into my eclipse. Suppose I wrote the following code:

List list = new ArrayList();

When I ctrl click on List, it shows two options. One of the option is Open Declaration which will show the methods in List interfaces. But when I click it it shows source not found. I've added java-util-1.8.0.jar to it but still it won't work. What am I doing wrong?

Upvotes: 1

Views: 2607

Answers (4)

Tarun
Tarun

Reputation: 838

See if you have a src.zip file in your JDK Home. This would contain the source code for all Java SE libraries. Just unzip and browse the Java files to view the source code.

If you want to debug through the source files then follow the instructions of attaching source folder in Eclipse as mentioned above.

Upvotes: 1

STaefi
STaefi

Reputation: 4377

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:

  1. Right click and select Properties (or press Alt+Enter) on your project.
  2. From the left tree styled menu select Java Build Path
  3. On the right select the Libraries
  4. Select the JRE System Library

enter image description here

  1. From the right side buttons click on edit, and edit the path from JRE location to points to the JDK location in your file system.

enter image description here

enter image description here

enter image description here

  1. 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.

Upvotes: 2

Harsh Patadia
Harsh Patadia

Reputation: 71

you have to add Eclipse Plugin from

HELP -> Eclipse Marketplace

I personally used

Enhanced Class Decompiler

just install it. and have fun.

Upvotes: 2

AConsumer
AConsumer

Reputation: 2781

Assuming you project is Maven one.Go the Project --> Right Click --> Maven -->Download Javadoc & sources. After performing these steps your problem will be resolved.

Upvotes: 0

Related Questions