在命令行下,如何使用JAD反编译jar文件
在命令行下,如何使用JAD反编译jar文件
版权声明:本文为博主原创文章,未经博主允许不得转载。
在工作中,我们经常需要对遗留系统或其他的第三方系统进行维护,如果我们没有Java源文件的情况下,一般都需要将其中的jar文件进行反编译。
本文将以如何用命令来反编译一个test.jar文件为例,你可以通过简单修改并将其放入到你的批处理脚本中,进行自动化反编译。
1)首先使用jar命令将jar文件解压缩到classes目录(假设你已经设置好了CLASSPATH等,jar.exe是放在jdk的bin目录下的)
CMD>jar -xvf test.jar -C classes
2)如果你没有下载过jad的软件,到http://www.kpdus.com/jad.html下载一个,并用解压缩工具将其解压缩到目录[jad_home]
3)然后使用jad命令对上面产生的classes目录进行反编译
CMD>[jad_home]/jad.exe -r -ff -d src -s Java classes/**/*.class
其中-r 表示恢复源文件的目录结构,,-ff 表示将类属性定义放在类方法定义之前, -d 表示输出目录,-s 表示文件的扩展名。
所有的java文件将会被放置到src目录下。
JAD Java Decompiler Download Mirror
As http://www.kpdus.com is no longer accessible, JAD Java Decompiler download is extremely hard to find. Here is a mirror where you can get JAD for various platforms.
- Jad 1.5.8g for Windows 9x/NT/2000 on Intel platform (238600 bytes).
- Jad 1.5.8g for Mac OS X 10.4.6 on Intel platform (170707 bytes, compiled by GCC 4.0).
- Jad 1.5.8e for HP-UX 11.x (293214 bytes).
- Jad 1.5.8e for Linux on Intel platform (214917 bytes).
- Jad 1.5.8e for Linux (statically linked) (389972 bytes) - take this version if the one above crashes or displays the "seek error" message.
- Jad 1.5.8d for OS/2 (288717 bytes) - OS/2 version was cross-compiled on Windows using EMX and RSXNT packages, therefore it requires EMX runtime (EMX.DLL should be enough).
- Jad 1.5.8c for FreeBSD 4.0 (322311 bytes) - statically linked.
- Jad 1.5.8c for OpenBSD 2.7 (334499 bytes) - statically linked.
- Jad 1.5.8c for NetBSD 1.5 (324440 bytes) - statically linked.
- Jad 1.5.8c for Solaris 8 on Intel platform (264751 bytes).
- Jad 1.5.8c for Mac OS X (Darwin 1.3) on PowerPC platform (266264 bytes).
- Jad 1.5.7g for Linux on Sun Sparc platform (180606 bytes).
- Jad 1.5.7g for Linux on Sun Sparc platform (346221 bytes) - statically linked.
- Jad 1.5.7f for Solaris 7 on Sun Sparc platform (318096 bytes) - compiled on Sun 4m (Sparc10) using GCC 2.8.1, statically linked. Works on Solaris 2.6 as well.
- Jad 1.5.7f for BeOS 5.0 on Intel platform (245422 bytes) - statically linked.
- Jad 1.5.7b for Mac OS X (Rhapsody 5.3) on PowerPC platform (372317 bytes).
- Jad 1.5.7a for Solaris 7 on Intel platform (252582 bytes) - try the version for Solaris 8 instead.
- Jad 1.5.5.3 for AIX 4.2 on IBM RS/6000 platform (360970 bytes).
Installation
Unzip jad.zip file into any appropriate directory on your hard drive. This will create two files:
- an executable file named 'jad.exe' (Windows 9x/NT/2000) or 'jad' (UNIX)
- README file 'Readme.txt', which contains the short user's manual
For UNIX users: make 'jad' executable: chmod a+x jad No further setup is required.
Disclaimer
JAD is Copyright 1997-2001 Pavel Kouznetsov.
All rights reserved.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE SOFTWARE IS NOT DESIGNED OR INTENDED FOR USE IN ON-LINE CONTROL OF AIRCRAFT, AIR TRAFFIC, AIRCRAFT NAVIGATION OR AIRCRAFT COMMUNICATIONS; OR IN THE DESIGN, CONSTRUCTION, OPERATION OR MAINTENANCE OF ANY NUCLEAR FACILITY. THE AUTHOR DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OFFITNESS FOR SUCH USES. YOU MUST REPRESENT AND WARRANT THAT YOU WILL NOT USE THE SOFTWARE FOR SUCH PURPOSES
Thanks to our sponsors who help keeping this software hosted and alive: Game Hero - Indie Game Developer Community.