简体   繁体   中英

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.

For taking a look into classes which come without source files (eg 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.

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM