Reverse Engineering in Java

 Reverse Engineering  is  some thing which i really wanted to do. It was just out of curiousity i tried it some time back when i was in my UG. Now it was a requirement for my project so i had to reverse Engineer a code  ie convert the .class file to .java file.

    I used Mocha written by Hanpeter van Vliet , One of the most used tool ,to reverse Engineer in Java.  It has around 200+ classes  in a .zip file.  There is no need to unzip the “” file contained in the distribution zip file; Java knows how to get .class files out of zip files. Simply put “” in a safe place, for instance the JDK directory. Add the full pathname of “” to your CLASSPATH string, for instance:

    SET CLASSPATH=c:\myclasses;c:\jdk\

 Now the next question would be to invoke it. 

Mocha is invoked from the commandline like this:

    java mocha.Decompiler [-v] [-o] Class1.class Class2.class …

   “java”               invokes the Java virtual machine,
   “mocha.Decompiler”   (note the case!) specifies the class to run,
   “-v”                 optionally specifies verbose output,
   “-o”                 optionally overwrites existing .mocha files,
   “ClassX.class”       specifies the .class file(s) to decompile.

Wildcards (* and ?) are accepted.

 Cool you just did a great Job of converting a compiled .class file back to your .java file




  1. @Abhinav
    You hit a nail on the Head.. Offcoz its illegal to reverse Engineer for commercial purpose , that too when its not your code. It is what you call as “INTELLECTUAL PLAGIARISM” having said that it doesnt mean that you shouldnt reverse Engineer to learn things. And My post is more of for latter purpose then the former.

  2. @ Hey Ashwin nice to meet you man! Great that you travelled all the way from Chennai to Bangalore to Attend the Academic Days. Ya i do love Java and now learning C# as well.

    @ Great to see that you remember dude.. Hows life? N when is Magnetics 06?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s