Showing posts with label Java .jar and .class De-compilation and recompilation. Show all posts

Java .jar and .class De-compilation and recompilation

Java .jar and .class de-compilation and recompilation

if you are familiar with java it is too good but hover you must be have to know that how to write program in java.Java is an advanced language it is mostly used in network based application and for cross platform development the java application execution architecture is as follow

Java code which are saved in .java file are compiled to .class file which basically execute on the JVM for distribution the .class files are packaged in .jar archives which also execute on the JVM so now as our binaries must be .class or .jar files so we have to work on those to reverse it the .class file have the name as that of .java and when the .class file is brought to JVM it frist start to execute main() function if it exists(in libraries there are no main() function) So our starting file in java files must be that one which have main.Now we know that .class is byte code executable on JVM files so we are going here to de-compile it to the .java so we can also use the .jar to be de-compiled the same way de-compilation process is below in simple steps

De-compilation of .Jar or .Class files

Ø First of all go to to the site and download “Java Decompiler
Ø if it does’t exists search in google “Java Decompiler” or Jd-Gui and download it
Ø It is a single stand alone Gui application just double click and open it
Ø An Application will pop up like below one

Ø This is Java Decompiler window
Ø Go to File menu and click on open
Ø Select your .jar or .class file and click on open
Ø And you will see the code as below in Java Decompiler

Ø Go to file and Click on Save all sources if you have opened a .Jar package
Ø The next step is to give name and it would be saved as named given a zip archive

Ø Save it
Ø Now you have successfully de-compiled the byte code
Ø It is now time to make changes in the code according to your needs
Ø Do it and save the .java file
Ø If your file contains too much class and codes you have to use extra tools to get to your required position
Ø Make the changes you want and save file

Recompilation of .java files

The java files compile easily with the java jdk(Java Development Kit) use it and compile your changed .java files. The process is easy but making the required change take a lot of time so you have to do it be patiently. Firstly you have to understand the code many tools can help you in the process there are a lot of free and paid tools those tool also recover the architecture and also to recover the class diagram this is the easiest type of Reverse Engineering you will find a lot of fun as we go further and further read on you can do it and you will learn a lot
Ø Keep in mind java program always start from main(String[] arg) function