Is it possible to convert a .class file to .java file?
How can this be done?
What about the correctness of the code extracted from this option?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is possible. You need a Java Decompiler to do this.
You’ll find mostly it’ll do a surprisingly good job. What you’ll get is a valid
.javafile which will compile to the.classfile but this.javafile won’t necessarily be the same as the original source code. Things like looping constructs might come out differently, and anything that’s compile time only such as generics and annotations won’t be re-created.You might have a problem if the code has been obfuscated. This is a process which alters the class files to make them hard to decompile. For example, class and variable names are changed to all be similar so you’ll end up with code like
aa.a(ab)instead ofemployee.setName(name)and it’s very hard to work out what’s going on.I remember using JAD to do this but I don’t think this is actively maintained so it may not work with never versions of Java. A Google search for java decompiler will give you plenty of options.