We all are aware that, when a java code is compiled, we get a .class file. This is called compilation. However is there a reverse process for this?? Yes. Its decompilation. Below is how we can convert .class file to a java file.
|There is a simpler way of doing this. Using a GUI tool named “JD-GUI 0.2.8“. You can get it from here.|
So, how to go about? Here is how,
- Download a decompiler called JAD from here.
- Choose ”Jad 1.5.8g for Windows 9x/NT/2000 on Intel platform “ if you’re using windows.(Skip this step if you have used the second link to download the JAD)
- You’ll get a jad.exe file from the download. Paste it inside the folder where your .class file is.
- Double clikc the jad.exe file once. Doing so jad cmd will appear and disappear.
- Open your command promt and change its directory path to wher your .class file exits. For eg., if your .class file is in c:/freddie/java, fire a command in command promt like cd c:/freddie/java.
- Lets assume you want to view helloworld.class, then fire a command like jad helloworld.class.
- A JAD file would be generated now.
- Fire another command like jad -sjava helloworld.class.
- Your helloworld.java file would have been created now.
That’s it my friends. These are the simple 9 steps to convert a .class file to a .java file (otherwise called as decompilation).
If you wish to decompile many .class files at a go, use the below command,
jad -sjava *.class
|Note: There is a simpler way of doing this. Using a GUI tool named “JD-GUI 0.2.8“. You can get it from here.|
I hope this is a valuable information for the needy