How to View a .class files? Use JAD

Hi,

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,

  1. Download a decompiler called JAD from here.
  2. 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)
  3. You’ll get a jad.exe file from the download. Paste it inside the folder where your .class file is.
  4. Double clikc the jad.exe file once. Doing so jad cmd will appear and disappear.
  5. 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.
  6. Lets assume you want to view helloworld.class, then fire a command like jad helloworld.class.
  7. A JAD file would be generated now.
  8. Fire another command like jad -sjava helloworld.class.
  9. 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).

Tip:

If you wish to decompile many .class files at a go, use the below command,

jad *.class

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 :)