在eclipse上安装反编译工具jd-eclipse

在eclipse上点一些类名的时候会弹出:

source not found:

The source attachment does not contain the source for the file String.class

 You can change the source attachment by clicking Change Attached Source below:

当然 你可以点击那个“Change Attached Source”的按钮,来指定你所需要的class的源文件路径

也可以用我现在要说的jd-eclipse工具

你可以在:http://java.decompiler.free.fr/?q=jdeclipse 下载到java decompiler的eclipse插件

然后你可以通过覆盖,或者eclipse>>help>>Install New Software来引入插件

但是我更喜欢用link文件的方式

把下载下来的eclipse插件解压放在eclipse目录下

比如:D:\Program Files\eclipse\jd-eclipse

在eclipse 目录新建个links文件夹,

在里面新建个文件jdclipse.link,文件名无所谓,只要后缀是.link

然后打开文件,写上path=jd-eclipse   这个jd-eclipse就是你jd相对于eclipse根目录的目录

保存就OK了

重启eclipse

随便点开一个class文件

可能会报一个错:

D:\Program Files\eclipse\configuration\org.eclipse.osgi\bundles\57\1\.cp\lib\linux\x86\libjd-eclipse.so: Can't load this .dll (machine code=0x101) on a IA 32-bit platform

出这个错的时候,你需要去你下载的压缩包里找到

jd.ide.eclipse.win32.x86_0.1.3.jar这个jar

解压他,在lib/win32/x86下复制jd-eclipse.dll文件

拷贝到D:\Program Files\eclipse\configuration\org.eclipse.osgi\bundles\57\1\.cp\lib\linux\x86\目录下,将jd-eclipse.dll重命名为libjd-eclipse.so将原来的覆盖掉

重启eclipse,你就可以看到反编译好的class文件了

当然,反编译的class文件是没有源码好看的,因为源码有大量的注释

猜你喜欢

转载自tankmarshal.iteye.com/blog/1623373