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 “mocha.zip” file contained in the distribution zip file; Java knows how to get .class files out of zip files. Simply put “mocha.zip” in a safe place, for instance the JDK directory. Add the full pathname of “mocha.zip” to your CLASSPATH string, for instance:
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