Jose Guerrero
Jose Guerrero

Reputation: 3

How can I see the code of a imported class in eclipse?

I want to see the source code of implemented classes in a package. I know how to access (by CTRL+click in the method or presing F3) but when I do that, it appears a message "source not found, The source attachment does not contain the source for the file..." I don't what to attach, it supposed that must be already attached because I can compile but I can't, I don't know what to do.

The program I'm using is Eclispe Luna.

Upvotes: 0

Views: 1750

Answers (4)

Massimo
Massimo

Reputation: 702

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.

Upvotes: 0

f_puras
f_puras

Reputation: 2504

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.

Upvotes: 1

gprathour
gprathour

Reputation: 15333

First of all let me clarify one thing, it is not mandatory that Source code is attached with all the libraries.

it supposed that must be already attached because I can compile

To complie the files you just need their .class files. Source code (.java file) is not necessary.

So it depends on which libraries you have downloaded and do they provide their source code or not.

Upvotes: 0

Dhanush Gopinath
Dhanush Gopinath

Reputation: 5749

If you having a Maven Project then in Window->Prefrences->Maven select the Download Artifact Sources option. This will auto download the source when you hit F3.

If the imported class doesn't have any source coming along in its Maven structure, then you can download the source, keep it in the local folder and attach it to the source using Import/Attach option that comes when you hit F3

Upvotes: 0

Related Questions