是否可以在另一个程序中反编译java .class文件? 我知道像CAVAJ和DJ Java Decompiler这样的工具。 为什么?:我正在修改程序中的类文件并将其转储到同一文件中。我想解析修改后的类文件的源文件。 提前谢谢。
答案 0 :(得分:1)
这是一个可能的答案(这是我用来编译源文件的)
private int runProcess(String command) throws Exception
{
Process pro = Runtime.getRuntime().exec(command);
System.out.println(command);
printLines("", pro.getInputStream());
printLines("",pro.getErrorStream());
pro.waitFor();
return(pro.exitValue());
}
然后你可以使用类似的东西:
int exitValue = runProcess(your command here);
我猜JD-GUI不起作用;你需要一个命令行java反编译器。
这些链接可能帮助:
Batch decompiling of Java files with JD-GUI
http://en.wikipedia.org/wiki/JAD_%28JAva_Decompiler%29
http://viralpatel.net/blogs/decompile-class-file-java-decompiler-class-java-class/
最后一个链接有一个下载链接到JAD,这是一个用于Windows计算机的命令行工具。
根据操作系统的不同,命令可能会有所不同,但如果将jad移动到cmd类路径,它可能只是“jad classname.class”。我有mac os x所以我不确定它的位置。
我希望这有帮助!
答案 1 :(得分:1)
如果您希望在运行时修改类,则可能不需要反编译该类。您可以操作字节码。看看http://cglib.sourceforge.net/,也许这会帮助你