Posted on 2010-07-10 15:31
斷點 閱讀(5898)
評論(2) 編輯 收藏 所屬分類:
Eclipse
在平時的項目中,經常需要開一下別人寫的源碼,而此時別人提供的往往是jar文件,根本看不了,很是不爽。最近很偶然的看見一個同事在eclipse下查看class文件,很是興奮。下面講下是如何安裝下插件的。
打開class文件,我目前了解的有2種類型的軟件:
一、
在eclipse外部打開jar文件。
Java Decompiler.exe,主頁JD home page:
http://java.decompiler.free.fr ,該軟件可以打開整個jar包,功能很強大。
二、
在eclipse內部打開jar文件。
net.sf.jadclipse_3.3.0.jar、jad158g.win.zip,需要這兩個文件。
準備工作:
1、下載jad.exe文件:
http://www.varaneckas.com/jad
2、下載jadeclipse插件:
http://sourceforge.net/projects/jadclipse/files/
安裝如下:
1、將jadeclipse插件net.sf.jadclipse_3.3.0.jar 拷貝到myeclipse安裝目錄E:\MyEclipse 6.0\eclipse\myplugins\jad\eclipse\plugins目錄下,并在目錄E:\MyEclipse 6.0\eclipse\links下新建文件jad.link,內容如下path=E:\\MyEclipse 6.0\\eclipse\\myplugins\\jad\\
2、將jad.exe解壓到指定目錄。如:D:\tools
3、在eclipse窗口下,點擊Window > Preferences > Java > JadClipse > Path to Decompiler。(設置jad的絕對路徑,如 D:\tools\jad\jad.exe)。Use Eclipse code formatter(overrides Jad formatting instructions)選項打勾,與格式化出來的代碼樣式一致。
4、在eclipse窗口下,點擊Window > Preferences > Java > JadClipse > Misc,將Convert Unicode strings into ANSI strings選項打勾,避免反編譯后可能出現的中文亂碼。
5、重新啟動myeclipse,eclipse自動將JadClipse Class File Viewer設置成class文件的缺省打開方式。如果沒有默認,可以在Eclipse的Window > Preferences >General >Editors> File Associations中修改“*.class”默認關聯的編輯器為“JadClipse Class File Viewer”。設置完成后,雙擊*.class文件,eclipse將自動反編譯。