出处:http://zhangwenzhuo.javaeye.com/blog/148201
【前言】师父昨天在我机器上调试,发现没有这个东东,就把我嘲笑了一把。。。。
Eclipse反编译插件: Jodeclipse与JadClipse
Jodeclipse 是Jode的Eclipse插件,JadClipse是Jad的Eclipse插件,它们都是非常好的反编译插件。
Jode Eclipse Plugin 1.0.5 for Eclipse version 3.1 / 3.2
安装方法
(1)从如下地址下载:
http://sourceforge.net/projects/jodeeclipse
把下载下来的文件jodeplugin_1.0.5.zip直接解压到eclipse的plugins目录下。
(2)启动eclipse,help -> Software Updates-> Find and Install... -> Search for new features to install,单击"New Remote Site..." 在URL栏输入 http://www.technoetic.com/eclipse/update然后下一步,就可以看到“jode decompiler plugin *.*”,选上安装就可以了。安装好后可以看到Window -> Preferences...-> Java -> Jode Decompiler选项卡,okay,安装成功了。
配置:Window-> Preferences... -> General -> Editors -> File Associations找到"*.class"在"Associated editors"里面可以看到"Jode class file viewer"选中它再单击Default按钮.
JadClipse Eclipse Plugin for Eclipse version 3.1 / 3.2/3.3
一、下载:
下载插件:
下载jadclipse_3.1.0.jar版本,该版本支持eclipse3.1M6~3.2M2
下载jadclipse_3.2.0.jar版本,该版本支持eclipse3.2M3和eclipse3.2M4.
下载jadclipse_3.2.4.jar版本,该版本支持eclipse3.2M5~3.3M5
下载jadclipse_3.3.0.jar版本,该版本支持eclipse3.3M6以上版本
下载Jad反编译工具:
http://www.kpdus.com/jad.html#download,在该页中找到适合自己操作系统平台的jad下载。下载后解压,然后将解压后的jad.exe文件复制到%JAVA_HOME%/bin目录下面(可以将jad.exe放到任意位置,只要记住其存放路径就好,下面要用到)。
二、安装:
Eclipse中的插件安装可以参考:Eclipse使用技巧
方法1、直接将jadclipse_x.x.x.jar(x.x.x.代表版本号)复制到%ECLIPSE_HOME%/plugins目录下。
方法2、使用link方式安装,建立D:/Myplugins/jadclipse3.2.4/eclipse/plugins的目录结构,将jadclipse_3.2.4.jar放到plugins目录下面(注:其中D:/Myplugins为你自己定义的一个专门放置插件的目录)。再在%ECLIPSE_HOME%/links目录下面建立一个jadclipse3.2.4.link文件(该文件名随便取)。文件里面内容为:path=D:/Myplugins/jadclipse3.2.4.
三、使用:
启动eclipse,点击反编译的类文件,此时会激活jadclipse插件,在eclipse菜单中会多出一个jadclipse菜单,如下图所示:
jadclipse插件
一般地它会自动反编译相应的class文件,如果没有自动反编译,请点击jadclipse->Decompile
如下图所示:
jadclipse插件反编译
常见问题及解决:
(一)启动eclipse,打开Window->Preferences->Java->JadClipse,如果没有找到JadClipse,即JadClipse插件没有激活。
(1)检查插件安装的版本是否与你安装的eclipse版本对应
(2)使用 –clean参数来启动eclipse
(二)在使用JadClipse插件反编译class文件时出现如下类似错误:
/*jadclipse*/
/*
DECOMPILATION REPORT
Decompiled from: E:/Java/jre1.5.0_12/lib/ext/j3dutils.jar
Total time: 63 ms
Jad reported messages/errors:
Exit status: 0
Caught exceptions:
java.io.IOException: CreateProcess: E:/Java/jdk1.5.0_12 -p -t4 -lradix10 -radix10 KeyNavigator.class error=5
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at net.sf.jadclipse.JadDecompiler.decompile(JadDecompiler.java:160)
at net.sf.jadclipse.JadDecompiler.decompileFromArchive(JadDecompiler.java:217)
at net.sf.jadclipse.JadclipseSourceMapper.findSource(JadclipseSourceMapper.java:150)
at net.sf.jadclipse.JadclipseSourceMapper.findSource(JadclipseSourceMapper.java:83)
at net.sf.jadclipse.JadclipseClassFileEditor.doOpenBuffer(JadclipseClassFileEditor.java:87)
at net.sf.jadclipse.JadclipseClassFileEditor.doSetInput(JadclipseClassFileEditor.java:45)
at net.sf.jadclipse.JadclipseActionBarContributor.setActiveEditor(JadclipseActionBarContributor.java:87)
at org.eclipse.ui.internal.EditorActionBars.partChanged(EditorActionBars.java:335)
at org.eclipse.ui.internal.WorkbenchPage$3.run(WorkbenchPage.java:606)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:843)
at org.eclipse.ui.internal.WorkbenchPage.activatePart(WorkbenchPage.java:595)
at org.eclipse.ui.internal.WorkbenchPage.setActivePart(WorkbenchPage.java:3203)
at org.eclipse.ui.internal.WorkbenchPage.activate(WorkbenchPage.java:588)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2604)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2528)
at org.eclipse.ui.internal.WorkbenchPage.access$10(WorkbenchPage.java:2520)
at org.eclipse.ui.internal.WorkbenchPage$9.run(WorkbenchPage.java:2505)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2500)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2485)
at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:287)
at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:164)
at org.eclipse.jdt.internal.ui.actions.OpenActionUtil.open(OpenActionUtil.java:49)
at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:190)
at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:174)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:267)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:243)
at org.eclipse.jdt.internal.ui.packageview.PackageExplorerActionGroup.handleOpen(PackageExplorerActionGroup.java:306)
at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$4.open(PackageExplorerPart.java:653)
at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:817)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
at org.eclipse.core.runtime.Platform.run(Platform.java:843)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:44)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:149)
at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:815)
at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1069)
at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1168)
at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:249)
at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:243)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:283)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
at org.eclipse.core.launcher.Main.run(Main.java:977)
at org.eclipse.core.launcher.Main.main(Main.java:952)
*/
请确保你的Jad路径在eclipse中正确制定。
启动eclipse,打开:Window->Preferences->Java->JadClipse.
1、Path to decompiler,这里设置反编译工具jad的全路径名,比如:%JAVA_HOME%/bin/jad.exe.
2、Directory for temporary files,这里设置临时文件路径。
至于Window->Preferences->Java->JadClipse目录下的Debug,Directives,Formatting,Misc目录中的参数设置,就不再罗嗦了。
(三)安装完成后,eclipse没有自动将JadClipse Class File Viewer设置成class文件的缺省打开方式。
如果没有默认,可以在Eclipse的Windows—> Perference—>General->Editors->File Associations中修改“*.class”默认关联的编辑器为“JadClipse Class File Viewer”。设置完成后,双击*.class文件,eclipse将自动反编译。