Filed under: Technology and Software
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:
SET CLASSPATH=c:\myclasses;c:\jdk\mocha.zip
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 …
Where
“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
cheers!!
11 Comments so far
Leave a comment
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



No cooments sir
Comment by Myshkin February 20, 2006 @ 7:48 amwhy must move blog from spaces.blogspot?
older blog was nice sir
Wudnt it be illegal to reverse engineer code ?!! especially if the original code aint yours !
pls clarify !
Comment by abhinav February 22, 2006 @ 8:37 pm@Abhinav
Comment by ranganaths February 23, 2006 @ 12:58 pmYou 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.
Hi! I have tagged you and you need to respond to it with a blog post.
Comment by Sunil Jagadish March 1, 2006 @ 10:17 amCheck – http://suniljagadish.blogspot.com/2006/03/tagged-twice.html
hey ranga, i came to blore for the academic days event and came to know abt u frm sharath. And even found out that u r a java freak (dats nice) cos even im one
.
About reverse engg. a java class file try this tool http://www.download.com/DJ-Java-Decompiler/3000-2417_4-10439692.html
keep in touch! Bye!
Comment by Aswin Anand March 6, 2006 @ 7:20 pmReverse Engineering ???? I guess i hv a long way to go … yes i do remember u … we first met @ christ college fest – 04 right … later @ magnetics .. hows dipanjan doing ?
Comment by Ankur Gupta March 7, 2006 @ 4:23 am@ 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?
Comment by ranganaths March 8, 2006 @ 8:41 amMagnetics 06 is on 13th and 14th of this month … juniors organizing this time … i guess u must hv completed ur MCA by now ? … ICFAI right
Comment by Ankur Gupta March 9, 2006 @ 3:29 amhey dude no man we are still in Final Year.. We will finish our MCA by this August.. anyways do give details about Magnetics man.. probably we can drop in..
Comment by ranganaths March 9, 2006 @ 4:21 pmsorry for the delay in response … we hv dispached an invitation @ ur college as on 10th … take a look @ http://theoxford.edu/magnetics for event related info …. registration is on spot
Comment by Ankur Gupta March 11, 2006 @ 6:37 amHello, I am trying to reverse some .class files with jcavaj. But i am getting 1st cannot be parsed and after giving ok i able to view the code. But is not running.can you guide me
Comment by Murthy December 19, 2008 @ 8:13 am