Thursday, January 27, 2011

Java Decompiler – Convert java class file to java source file

There are many Java Decompilers available. The Best one I have found was the JAD Decompiler and sharing it to you people.
You can download the JAD Decompiler for different OS from the following website.
When you unzip, you can find two files JAD.exe and Readme.txt. It is easy to learn, understand how to use the JAD from the Readme.txt file. I will give simple information on how to use it. There are some simple commands you need to use to convert .class to .java.
For windows,
Place the JAD.exe at the location of the .class file or the folder contains .class files. Open the Command Prompt. Navigate to the location of the JAD.
If you don’t know how to use Command Prompt
{
If the .Class file location is at D:\Project\Sample. Open the command prompt by Start->Run->(Type  “cmd”) or Hold Windows Key and Press R Key. It will show some location on it. Type “d:” and hit enter. The D: location will be shown. Type “cd D:\Project\Sample” and hit enter. You will get the path on Command Prompt. Then continue with the decompilation on command prompt at D:\Project\Sample>
}
## To decompile a single JAVA class file 'example1.class', type the following:

jad -sjava example1.class

This command creates file 'example1.java'.

## If you want to decompile the whole tree of JAVA classes,use the following command:

jad -o -r -sjava -dsrc tree/**/*.class

This command decompiles all .class files located in all subdirectories of 'tree' and creates output files in subdirectories of 'src' according to package names of classes. For example, if file 'tree/a/b/c.class' contains class 'c' from package 'a.b', then output file will have a name 'src/a/b/c.java'.

Hope it is useful!!!
Have Fun:)

No comments:

Post a Comment