Decompile Java Class file using decompilers.

duke-java-mascotByte codes generated by javac compiler can again be converted into java source. For this we need a decompiler tool. Decompilers are the utilities that generate the source code from input java class file. A Decompiler knows about the structure of a Java class and parse it to generated Java source code. Java decompilers will not give the exact Java source file from which class was generated and executed by Java Virtual Machine. But most of the structure will be maintained.

JAD: Java Decompiler

A lot of Decompilers are available in the market to decompile a class file. We will use one of the free decomipler called JAD. You can download JAD compiler from here. Update: JAD’s site is down hence you can download it from this link. I have used a simple Hello World java class to demonstrate JAD decompiler. Following is the code of file.
public class HelloWorld { public static void main(String args[]) { String fooBar = "Hello World from Java."; System.out.println(fooBar); } }
Code language: Java (java)
Use following output when we use command line utility JAD to decompile our class file.
$> jad HelloWorld.class Parsing HelloWorld.class... Generating HelloWorld.jad
Code language: HTML, XML (xml)
The source file output of JAD is in file with .jad extension. You can change the extension to .java. Following is the source that you get after decompillng our HelloWorld.class file.
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov. // Jad home page: // Decompiler options: packimports(3) // Source File Name: import; public class HelloWorld { public HelloWorld() { } public static void main(String args[]) { String s = "Hello World from Java."; System.out.println(s); } }
Code language: Java (java)
Note that the string variable that we used in our original Java class was fooBar and it got changed into s. Any idea why so?
Get our Articles via Email. Enter your email address.

You may also like...


  1. q666 says:

    The reason for the change is Refactorization/Optimization , when the compiler is compiling the source it`s grabbing the long variable names in this case “FooBar” and replace it to some shorter versions for example “s” i think that most of the compilers are doing it.

  2. jakob says:

    Your wordpress theme generates an error:

    Warning: ob_start() [ref.outcontrol]: output handler ‘ob_gzhandler’ cannot be used twice in /home/viralpat/public_html/blogs/wp-content/themes/wp-max/header.php on line 1

  3. Hi Jakob,
    Thanks for pointing out the error. Actually I was trying to enable GZip compression for my website and hence was playing with .htaccess ;)
    Are you still getting the error?

  4. prashant says:

    Hi Viral,

    It is very good tool.
    But currently it is not existing.

    Here i have a lot of list of available decompilers.
    Just see,It is very useful

  5. kungfugeek says:

    The page expired in late February. Is there another place I can dl the executable?

  6. Thanks kungfugeek, I have updated the link. You can download JAD from this site.

  7. hope you will not mind if I link your “” download from my Blog


  8. Hi FreddieMaize, You can link to from your site. No problem :)

  9. ivmai says:

    To achieve better results (including for Java 1.5+ classes) in decompilation, process the classes with JadRetro ( tool before decompiling them by Jad.
    Of course, it doesn’t help in your case with “fooBar” variable because javac doesn’t put local variable names to the generated class file unless instructed to do so (-g:vars).

  10. sharmabhabho says:

    Thank you for sharing so much information. May be this information would help me in developing an application in future. Right now i am excited to go to attend the Sun Tech Days 2010 conference in Hyderabad. Experts are going to share ideas on new technologies there.

  11. sharda says:

    good site but some clear idea about java decaffinator.plz require that information.

  12. Atanas says:

    There is another java decompiler:
    AndroChef successfully decompiles obfuscated Java 6 and Java 7 .class and .jar files. It is simple but powerful tool that allows you to decompile Java and Dalvik bytecode (DEX, APK) into readable Java source.

  13. Good tool.

  14. Samriti says:– this is good.

  15. manikandan says:

    thank you

  16. raju cha cha says:


  17. dipendra says:

    buddy u rock………….thanks alot

  18. mohafadli says:

    thanks a lot Mr. Viral Patel, keep posting :)

  19. himanshu says:

    just trying to download but the download dialog doesn’t appear

  20. himanshu says:

    it’s urgent do something plzzzzzzzzz the link doesn’t work

  21. nelson says:

    this is a old post, but i learned something that the java file decompiled from .class is not the original one. :)

Leave a Reply

Your email address will not be published. Required fields are marked *