今天安装jad和jadclipse 反编译.class 文件,方便查看线上的jar包源码
一:安装jadclipse (提供了运行jad的接口页面)
A:下载 http://jadclipse.sourceforge.net/
B:解压,jar包放在eclipse的puglins文件夹下
C:重启eclipse,可看到如下jadClipse已经出现在导航栏
二:下载jad(可以不装jadclipse,在命令行运行jad,真正的反编译工作是jad来做的)
A:下载 http://varaneckas.com/jad/
B:解压,将jad.exe 放置在某个文件夹下
三:配置jadClipse的jad路径
A: eclipse的windows>preference>java>jadClipse 的path配置刚才jad.exe的绝对路径
B: 查看配置:eclipse的windows>preference>Gerneral>Editors>File Association 中配置.class 文件的关联编辑器
ok,说明.class 文件应该可以被反编译了,双击.class 文件,就可以看到source code啦
四:安装出现的问题
(1)反编译一个文件出现下面结果(jad 版本错误,更新之后成功):
/*jadclipse*/Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov (kpdus@yahoo.com).
Usage: jad [option(s)]
Options: -a - generate JVM instructions as comments (annotate)
-af - output fully qualified names when annotating
-b - generate redundant braces (braces)
-clear - clear all prefixes, including the default ones
-d
- directory
for output files
-dead - try to decompile dead parts of code (if there are any)
-dis - disassembler only (disassembler)
-f - generate fully qualified names (fullnames)
-ff - output fields before methods (fieldsfirst)
-i - print default initializers for fields (definits)
-l - split strings into pieces of max chars (splitstr)
-lnc - output original line numbers as comments (lnc)
-nl - split strings on newline characters (splitstr)
-noconv - don't convert Java identifiers into valid ones (noconv)
-nocast - don't generate auxiliary casts
-nocode - don't generate the source code for methods
-noctor - suppress the empty constructors
-nodos - turn off check for class files written in DOS mode
-noinner - turn off the support of inner classes
-nolvt - ignore Local Variable Table entries (nolvt)
-nonlb - don't insert a newline before opening brace (nonlb)
-o - overwrite output files without confirmation
-p - send all output to STDOUT (for piping)
-pa - prefix for all packages in generated source files
-pc - prefix for classes with numerical names (default: _cls)
-pe - prefix for unused exception names (default: _ex)
-pf - prefix for fields with numerical names (default: _fld)
-pi - pack imports into one line using .* (packimports)
-pl - prefix for locals with numerical names (default: _lcl)
-pm - prefix for methods with numerical names (default: _mth)
-pp - prefix for method parms with numerical names (default:_prm)
-pv - pack fields with the same types into one line (packfields)
-r - restore package directory structure
-s - output file extension (default: .jad)
-space - output space between keyword (if, while, etc) and expression
-stat - show the total number of processed classes/methods/fields
-t - use spaces for indentation (default: 4)
-t - use tabs instead of spaces for indentation
-v - show method names while decompiling
/*
DECOMPILATION REPORT
Decompiled from: D:Program FilesMyEclipse 6.0jrelib t.jar
Total time: 141 ms
Jad reported messages/errors:
Exit status: 1
Caught exceptions:
*/