简体   繁体   English

如何从rt.jar反编译Java .class文件

[英]How to decompile a Java .class file from rt.jar

I have extracted a .class file from the rt.jar file in jre1.7, and have attempted to open it using notepad++, however it is unreadable. 我已经从jre1.7的rt.jar文件中提取了一个.class文件,并尝试使用notepad ++打开它,但是它不可读。 How can I decompile the .class file into a .java file so I can view the code? 如何将.class文件反编译为.java文件,以便查看代码?

Please note that I am interested in the decompilation of the code, not viewing the source code provided in the JDK downloads. 请注意,我对代码的反编译感兴趣,而不是查看JDK下载中提供的源代码。

As @Jon Skeet said, don't use JRE but JDK, which contains the entire source code. 就像@Jon Skeet所说的,不要使用JRE,而是使用JDK,它包含整个源代码。 If you for some reason insist on your approach, then I recommend JD-GUI for decompilation. 如果您出于某种原因坚持使用您的方法,那么我建议您使用JD-GUI进行反编译。

.class files are the compiled binary files. .class文件是已编译的二进制文件。 You can't read the Java code from them, but you can run them. 您无法从它们中读取Java代码,但是可以运行它们。 If you want to see the source you usually need .java files. 如果要查看源,通常需要.java文件。 These are either packed in the same jar but then the src folder, or they can be downloaded in a seperate package. 它们要么打包在同一个jar中,然后打包在src文件夹中,要么可以单独下载。

You can use any decompiler tool like cavaj for decompiling a class file to source code (java file). 您可以使用诸如cavaj之类的任何反编译器工具将类文件反编译为源代码(java文件)。 I'm using it, and it works perfectly. 我正在使用它,并且效果很好。

Try any of the decompilers listed here: 尝试在此处列出的任何反编译器:

Or use online decompiler - http://www.javadecompilers.com/ 或使用在线反编译器-http: //www.javadecompilers.com/

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

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