有人知道可以反编译整个Jar文件而不是单个类的免费反编译器吗?我有一个问题的子类,如名称$1.类名称$2.类名称
当前回答
将以下内容插入到decompile.jar.sh中
# Usage: decompile.jar.sh some.jar [-d]
# clean target folders
function clean_target {
rm -rf $unjar $src $jad_log
}
# clean all debug stuff
function clean_stuff {
rm -rf $unjar $jad_log
}
# the main function
function work {
jar=$1
unjar=`basename $jar.unjar`
src=`basename $jar.src`
jad_log=jad.log
clean_target
unzip -q $jar -d $unjar
jad -d $src -ff -r -lnc -o -s java $unjar/**/*.class > $jad_log 2>&1
if [ ! $debug ]; then
clean_stuff
fi
if [ -d $src ]
then
echo "$jar has been decompiled to $src"
else
echo "Got some problems check output or run in debug mode"
fi
}
function usage {
echo "This script extract and decompile JAR file"
echo "Usage: $0 some.jar [-d]"
echo " where: some.jar is the target to decompile"
echo " use -d for debug mode"
}
# check params
if [ -n "$1" ]
then
if [ "$2" == "-d" ]; then
debug=true
set -x
fi
work $1
else
usage
fi
Chmod +x compile .jar.sh //可执行文件 Ln -s ./ compile .jar。年代/usr/bin/dj
准备使用,只需输入dj你的。jar,你会得到你的。jar.src文件夹的源代码。调试模式使用-d选项。
其他回答
首先,值得记住的是,所有Java归档文件(.jar/.war/等等…)基本上都是花哨的.zip文件,并添加了一些清单和元数据。
其次,为了解决这个问题,我个人使用了几个可以在各个层面处理这个问题的工具:
Jad + Jadclipse,在IDE中编译。class文件 WinRAR是我最喜欢的压缩工具,它支持Java存档(请参见第一段)。 Beyond Compare是我最喜欢的差异工具,如果配置正确,它可以在任何归档文件(包括jar)之间进行动态比较。值得一试。
前面提到的优点是,我不需要持有任何其他外部工具,使我的工作环境混乱。我从这些文件中需要的任何东西都可以在我的IDE中处理,或者与其他文件本地进行区别。
喜欢的东西:
jar -xf foo.jar && find . -iname "*.class" | xargs /opt/local/bin/jad -r
也许?
注意:此解决方案仅适用于Mac和*nix用户。
我也试过找杰德,但一无所获。我的快速解决方案是下载包含jad的MacJad。一旦你下载了它,你可以在[where-you-download - MacJAD]/MacJAD/Contents/Resources/jad中找到jad。
将以下内容插入到decompile.jar.sh中
# Usage: decompile.jar.sh some.jar [-d]
# clean target folders
function clean_target {
rm -rf $unjar $src $jad_log
}
# clean all debug stuff
function clean_stuff {
rm -rf $unjar $jad_log
}
# the main function
function work {
jar=$1
unjar=`basename $jar.unjar`
src=`basename $jar.src`
jad_log=jad.log
clean_target
unzip -q $jar -d $unjar
jad -d $src -ff -r -lnc -o -s java $unjar/**/*.class > $jad_log 2>&1
if [ ! $debug ]; then
clean_stuff
fi
if [ -d $src ]
then
echo "$jar has been decompiled to $src"
else
echo "Got some problems check output or run in debug mode"
fi
}
function usage {
echo "This script extract and decompile JAR file"
echo "Usage: $0 some.jar [-d]"
echo " where: some.jar is the target to decompile"
echo " use -d for debug mode"
}
# check params
if [ -n "$1" ]
then
if [ "$2" == "-d" ]; then
debug=true
set -x
fi
work $1
else
usage
fi
Chmod +x compile .jar.sh //可执行文件 Ln -s ./ compile .jar。年代/usr/bin/dj
准备使用,只需输入dj你的。jar,你会得到你的。jar.src文件夹的源代码。调试模式使用-d选项。
我使用一个名为(令人沮丧的)JD: Java反编译器。
我发现在处理为Java 5或更高版本编译的类时,它比大多数反编译器都要好。不幸的是,在JAD通常会成功的地方,它仍然会有一些问题。
推荐文章
- .toArray(new MyClass[0]) or .toArray(new MyClass[myList.size()])?
- Hibernate中不同的保存方法之间有什么区别?
- Java 8流和数组操作
- Java Regex捕获组
- Openssl不被视为内部或外部命令
- 如何添加自定义方法到Spring Data JPA
- 如何在Ubuntu中设置Java环境路径
- 无法执行dex:在Eclipse中超过GC开销限制
- 有人能解释一下JPA和Hibernate中的mappedBy吗?
- 是什么导致JNI调用变慢?
- Java中的&和&&有什么区别?
- 使用Java的Collections.singletonList()?
- Maven使用多个src目录编译
- 导入时无法解析符号
- 用谓词限制流