简体   繁体   English

反编译java类文件

[英]Decompile java class file

Is it possible to decompile a java .class file within another program ?是否可以在另一个程序中反编译 java .class 文件? I'm aware of tools like CAVAJ and DJ Java Decompiler.我知道像 CAVAJ 和 DJ Java Decompiler 这样的工具。 Why ?为什么 ? : I'm modifying a class file within the program and dumping it into the same. :我正在修改程序中的一个类文件并将其转储到同一个文件中。 I want to then parse the source file of the modified class file.我想然后解析修改后的类文件的源文件。 Thanks in advance.提前致谢。

Here is a possible answer (this is what I use for compiling source files)这是一个可能的答案(这是我用来编译源文件的)

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());
}

Then you can use something like:然后你可以使用类似的东西:

int exitValue = runProcess(your command here);

I guess JD-GUI will not work;我猜 JD-GUI 不会工作; you need a command line java decompiler.你需要一个命令行java反编译器。

These links might help:这些链接可能会有所帮助:
Batch decompiling of Java files with JD-GUI 使用 JD-GUI 批量反编译 Java 文件
http://en.wikipedia.org/wiki/JAD_%28JAva_Decompiler%29 http://en.wikipedia.org/wiki/JAD_%28JAva_Decompiler%29
http://viralpatel.net/blogs/decompile-class-file-java-decompiler-class-java-class/ http://viralpatel.net/blogs/decompile-class-file-java-decompiler-class-java-class/

The last link has a download link to JAD, a command line tool for windows computers.最后一个链接有一个 JAD 的下载链接,JAD 是 Windows 计算机的命令行工具。

Depending on the OS the command might vary but it might just be "jad classname.class" if you move jad to your cmd class path.根据操作系统,命令可能会有所不同,但如果您将 jad 移动到 cmd 类路径,它可能只是“jad classname.class”。 I have mac os x so I am not sure where this is located.我有 mac os x,所以我不确定它在哪里。

I hope this helps!我希望这有帮助!

If you're looking to modify the class at runtime it may not be needed to decompile the class.如果您希望在运行时修改该类,则可能不需要反编译该类。 You can manipulate the bytecode.您可以操作字节码。 Take a look at http://cglib.sourceforge.net/ , maybe that'll help you看看http://cglib.sourceforge.net/ ,也许这会帮助你

Java IDE works fine to decompile class files. Java IDE 可以很好地反编译类文件。 Try IntelliJ as an example, even Community Edition.以 IntelliJ 为例,甚至社区版。 It is not able to update (read only mode) but I hope it can help它无法更新(只读模式)但我希望它可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM