2

Possible Duplicate:
How do I “decompile” Java class files?

I m new to java and i was wondering if there is a way to retrieve the source code of a file (i.e. the .java file) from its compiled file (.class file).

I have read about the compilation process i.e. about the parsing, the syntax and semantics trees, the intermediate code generation, macros used etc. It sounded like a very complex process. Reverse engineering it will be even more difficult. Therefore, I think it is not possible but i had to ask. I googled it but couldn't find anything satisfactory.

Also i learnt about code-obfuscation in my class. If de-compilation is possible how will it behave for an obfuscated file?

Thanks in advance.

Community
  • 1
  • 1

2 Answers2

0

[edit : I won't complete the answer as this question is a duplicate, this is just an additionnal comment on the second part of the question]

When you obfuscate a class, you remove everything that isn't needed for the execution but is present in the file, like the names of the method.

In fact, obfuscating an isolated class doesn't remove a lot because other classes need the names of the methods or visible fields. So usually you obfuscate a group of class togethers using a tool like proguard.

Denys Séguret
  • 372,613
  • 87
  • 782
  • 758
0

Yes there is, very simple by the way, get a program called DJ Java Decompiler (search in google it's easy to find) and after you install it, you just have to open the .class file, and it shows the code all formatted and indented. Microsoft Windows only application

Grego
  • 2,220
  • 9
  • 43
  • 64
  • You have to note that this particular program only works on windows and that you have to configure it appropriately to open/decompile classes. If you want to integrate it with you IDE, there are several more steps that would need to be taken, depending on the ide. – Aleks G Jun 10 '12 at 18:13
  • yea I know but he said: "... i was wondering if there is a way to retrieve the source code of a file." if he wants to decompile a file, this is a great program for it. – Grego Jun 10 '12 at 18:15