有人知道可以反编译整个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选项。

其他回答

如果你碰巧有bash shell和jad:

JAR=(your jar file name)
unzip -d $JAR.tmp $JAR
pushd $JAR.tmp
for f in `find . -name '*.class'`; do
    jad -d $(dirname $f) -s java -lnc $f
done
popd

我可能有一点点,一点点的偏差,但它应该或多或少像宣传的那样有效。您应该得到包含反编译文件的$JAR.tmp。

你提取它,然后对dir使用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选项。

注意:此解决方案仅适用于Mac和*nix用户。

我也试过找杰德,但一无所获。我的快速解决方案是下载包含jad的MacJad。一旦你下载了它,你可以在[where-you-download - MacJAD]/MacJAD/Contents/Resources/jad中找到jad。

2022年更新:QuiltMC/quiltflower是最新最先进的Java反编译器:

Quiltflower是一个现代的通用反编译器,专注于提高代码质量、速度和可用性。 Quiltflower是Fernflower和Forgeflower的分叉。

Changes include: New language features (Try with resources, switch expressions, pattern matching, and more) Better control flow generation (loops, try-catch, and switch, etc.) More configurability Better error messages Javadoc application Multithreading Optimization Many other miscellaneous features and fixes Originally intended just for use with the QuiltMC toolchain with Minecraft, Quiltflower quickly expanded to be a general purpose java decompiler aiming to create code that is as accurate and clean as possible. If the name sounds familiar it's because Quiltflower is a fork of Fernflower, the (in)famous decompiler that was developed by Stiver, maintained by Jetbrains, and became the default decompiler in Intellij IDEA. Fernflower also quickly found its way into many other tools. Over the past year, Quiltflower has added support for features such as modern string concatenation, a code formatter, sealed classes, pattern matching, switch expressions, try-with-resources, and more. Quiltflower also focuses on the code quality of the decompiled output, and takes readability very seriously.

请参阅输出示例。

运行jbang很好 https://github.com/QuiltMC/quiltflower/releases/download/1.8.1/quiltflower-1.8.1.jar

Or:

jar quiltflower.jar -dgs=1 c:\Temp\binary\library.jar c:\Temp\binary\Boot.class


2009: JavaDecompiler可以很好地处理jar:从0.2.5开始,将显示jar文件中的所有文件。

另见问题“我如何”反编译“Java类文件?”。

不过,JD-Eclipse自2009年底以来似乎没有变化(参见变化)。 因此,它与最新的Eclipse(3.8, 4.2+)的集成可能存在问题。

积极维护JD-Core。

两者都是(SO用户)Emmanuel Dupuy出色工作的结果。


2018年:一个更现代的选择,大卫·肯尼迪·阿劳霍在评论中提到:

JetBrains / intellij-community /插件/ java-decompiler /引擎

Fernflower是Java的第一个实际工作的分析反编译器,可能对于一般的高级编程语言也是如此。 Java -jar fernflower.jar [-<option>=<value>]* [<source>]+ <destination> .jar] [-<option>=<value> java -jar fernflower.jar -hes=0 -hdc=0 c:\Temp\binary\ -e=c:\ java \rt.jar c:\Temp\source\

请参见如何反编译到java文件intellij idea的命令与最近的intellij idea。


2022年更新:弗洛里安·温德尔伯恩在评论中建议

这个很好用:jdec。莱昂纳多·桑托斯的app。