5

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. Thanks

Cole G
  • 51
  • 1
  • 2

5 Answers5

7

You can use a decompiler to do so. One of the most major ones is JD-GUI.

JD-Core is a library that reconstructs Java source code from one or more “.class” files. JD-Core may be used to recover lost source code and explore the source of Java runtime libraries. New features of Java 5, such as annotations, generics or type “enum”, are supported. JD-GUI and JD-Eclipse include JD-Core library.

EDIT (2018-02-23): It seems that JD-GUI is incapable of decompiling bytecode compatible with Java 8+ JREs. 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. It's very similar to JD-GUI, but supports Java 8 byte code, itself being based on Procyon.

ifly6
  • 5,003
  • 2
  • 24
  • 47
1

You can use any of the java decompiler utility for this. There are a couple of few good utilities available over the internet, e.g., JD decompiler, you can also look for the eclipse plugin as well for the same.

Aman Gupta
  • 53
  • 8
1

To view java content from .class files many decompilers are available. I'm using JD compiler which is very good. http://jd.benow.ca/ If you want it for edit/ update puropse, one way is copy + paste from decompilers. Other solutions i'm not aware of.

0

You can use Jadclipse which is basically a Java Decompiler. It can be used with eclipse integration..

Bharat
  • 119
  • 2
  • 4
  • 17
0

You can use decompiler to get .java files from a jar file or a .class file

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 12 '21 at 21:21