简体   繁体   English

你能从Java中的.class文件中获取.java文件吗?

[英]Can you get a .java file from a .class file in Java

Was given a couple of .class files but the .java files weren't sent with and I was hoping to find a way to get the .java files using the .class files. 给了几个.class文件,但.java文件没有发送,我希望找到一种方法来使用.class文件获取.java文件。 Thanks 谢谢

You can use a decompiler to do so. 您可以使用反编译器来执行此操作。 One of the most major ones is JD-GUI. 其中最重要的是JD-GUI。

JD-Core is a library that reconstructs Java source code from one or more “.class” files. JD-Core是一个从一个或多个“.class”文件重构Java源代码的库。 JD-Core may be used to recover lost source code and explore the source of Java runtime libraries. JD-Core可用于恢复丢失的源代码并探索Java运行时库的源代码。 New features of Java 5, such as annotations, generics or type “enum”, are supported. 支持Java 5的新功能,例如注释,泛型或类型“枚举”。 JD-GUI and JD-Eclipse include JD-Core library. JD-GUI和JD-Eclipse包括JD-Core库。

EDIT (2018-02-23): It seems that JD-GUI is incapable of decompiling bytecode compatible with Java 8+ JREs. 编辑(2018-02-23):似乎JD-GUI无法反编译与Java 8+ JRE兼容的字节码。 This, obviously, changes the utility of my answer. 显然,这改变了我的答案的实用性。

EDIT (2018-05-24): For replacing JD-GUI, I would recommend Luyten, which can be found here . 编辑(2018-05-24):为了取代JD-GUI,我推荐Luyten,可以在这里找到。 It's very similar to JD-GUI, but supports Java 8 byte code, itself being based on Procyon . 它与JD-GUI非常相似,但支持Java 8字节代码,本身基于Procyon

You can use any of the java decompiler utility for this. 您可以使用任何java反编译器实用程序。 There are a couple of few good utilities available over the internet, eg, JD decompiler, you can also look for the eclipse plugin as well for the same. 互联网上有一些很好的实用程序,例如JD反编译器,你也可以查找eclipse插件。

To view java content from .class files many decompilers are available. 要查看.class文件中的java内容,可以使用许多反编译器。 I'm using JD compiler which is very good. 我正在使用非常好的JD编译器。 http://jd.benow.ca/ If you want it for edit/ update puropse, one way is copy + paste from decompilers. http://jd.benow.ca/如果你想要它用于编辑/更新puropse,一种方法是从反编译器复制+粘贴。 Other solutions i'm not aware of. 我不知道的其他解决方案。

You can use Jadclipse which is basically a Java Decompiler. 您可以使用基本上是Java Decompiler的Jadclipse。 It can be used with eclipse integration.. 它可以与eclipse集成一起使用..

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

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