標籤:style blog http java color 使用
Eclipse反編譯工具Jad及外掛程式JadClipse配置
Jad是一個Java的一個反編譯工具,是用命令列執行,和通常JDK內建的java,javac命令是一樣的。不過因為是控制台運行,所以用起來不太方便。不過幸好有一個eclipse的外掛程式JadClipse,二者結合可以方便的在eclipse中查看class檔案的原始碼。下面介紹一下配置:
A.下載JadClipse,http://jadclipse.sourceforge.net/wiki/index.php/Main_Page#Download,注意選擇與eclipse版本一致的版本,我用的是Eclipse3.4,所以選擇下載版本net.sf.jadclipse_3.3.0.jar
B.下載Jad,http://www.varaneckas.com/jad,下載相應版本
C.將下載下來的Jadclipse,如net.sf.jadclipse_3.3.0.jar拷貝到Eclipse下的plugins目錄即可。當然也可以用links安裝,不過比較麻煩。
D.將Jad.exe拷貝到JDK安裝目錄下的bin檔案下(方便,與java,javac等常用命令放在一起,可以直接在控制台使用jad命令),我的機器上的目錄是D:\Program Files\Java\jdk1.6.0_02\bin\jad.exe
F.然後,重新啟動Eclipse,找到Eclipse->Window->Preferences->Java,此時你會發現會比原來多了一個JadClipse的選項,單擊,會出現,如下:,在Path to decompiler中輸入你剛才放置jad.exe的位置,也可以制定臨時檔案的目錄,。。當然在JadClipse下還有一些子選項,如Debug,Directives等,按照預設配置即可。
G.基本配置完畢後,我們可以查看一下class檔案的預設開啟檔案,Eclipse->Window->Preferences->General->Editors->File Associations,我們可以看到:
,我們可以看到class檔案的開啟檔案有兩個,JadClipse和Eclipse內建的Class File Viewer,而JadClipse是預設的。
H.全部配置完成,下面我們可以查看源碼了,選擇需要查看的類,按F3即可查看源碼,如查看Annotation中的Target,使用jad查看源碼如下:
大家可以看到最上面的一行
"/*jadclipse*/// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.",說明是由jad反編譯的。
PS:網上說對於存在原始碼的類,它不會強行反編譯,也就是說它還是會用eclipse內建的Class File Viewer查看class檔案。這個我還沒有進行過驗證。 另外附上我用的jad和jadclipse的壓縮包,方便大家下載:/Files/landon/DeComiler.rar
Installation
- Put the JadClipse JAR file into the plugins folder of your Eclipse installation.
- Restart Eclipse (eclipse -clean).
- Get Jad.
- Put the Jad executable into a directory that is in the execution path of your operating system. Alternatively, you can configure the path to the Jad executable under Window > Preferences... > Java > JadClipse > Path to Decompiler. (Set the full path, e.g. C:\Program Files\Jad\jad.exe)
- Go to Window > Preferences... > General > Editors > File Associations and make sure that the JadClipse Class File Viewer has the default file association for *.class files.
Troubleshooting
-
The JadClipse plug-in is not activated when I start Eclipse.
-
You‘ll need to launch Eclipse with the -clean flag to allow the environment to detect the plug-in. Subsequent launching of Eclipse won‘t require the -clean flag.
eclipse -clean
-
The Eclipse Class File Viewer instead of the JadClipse Class File Viewer is opened.
-
Go to
Window > Preferences... > General > Editors > File Associations and make sure that the JadClipse Class File Viewer has the default file association for *.class files.
-
The JadClipse Class File Viewer does not show the decompiled source.
-
If the editor contains the following text segment JadClipse was not able to execute the Jad binary. Make sure that the path to the binary (Path to Decompiler) is set correcly in the preferences.
/*jadclipse*//*DECOMPILATION REPORTDecompiled from: D:\Program Files\Java\jdk1.5.0_06\jre\lib\rt.jarTotal time: 16 msJad reported messages/errors:Exit status: 0Caught exceptions:java.io.IOException: CreateProcess: (...)
http://jadclipse.sourceforge.net/wiki/index.php/Main_Page#Installation
http://jd.benow.ca/jd-gui/downloads/#jd-gui
jd-gui
jd-gui-0.3.6.windows.zip
http://jd.benow.ca/jd-gui/downloads/jd-gui-0.3.6.windows.zip
http://blog.sina.com.cn/s/blog_437ff56b010166qb.html