I started learning Java. But, until recently, I had no idea about the same. I didn't knew that something magical existed that would perform thisconversion. But now since I know a bit, I thought I better share it.

Java Decompiler

As you would have guessed by now, a Java Decompiler is a computer program capable of reversing the work done by a Compiler. In essence, it can convert back the Bytecode (the .class file) into the source code (the .java file).

There are many decompilers that exist today, but we will talk about the most widely used JD - Java Decompiler, which is available both as astand-alone GUI program and as an Eclipse-plugin.

To install and use these tools are a breeze and would not take you more than a few minutes to get accustomed to it. Hence, I would not repeat the process that's already mentioned on their site.One thing that we must note here is that the process of conversion mightNOT result into 100% exact code, i.e. the generated Java file might not match the actual Java code character by character. However, most of the code would be replicated but things like variable & function names or some other minor details may differ.L

ets have a look at the JD-GUI, stand-alone tool, written in C++;making it pretty fast to execute(decompile) and display the result. Also, it isindependent of the the Java Runtime Environment and thus no setup is required to install it.

Lets test the tool now.

Example Java Code:

public class test{
public static void main(String[] args){
System.out.println("Hello world");

Compile it: javac test.java

so that we have ByteCode (test.class file) with us now.

Decompile it using any one of the following ways:

Execute the following on the command line: jdi-gui.exe test.class

Select 'Open File' from the menu, browse to get to the test.class file and open it

Drag and Drop the test.class file into the JD-GUI tool

All of the above situations result in generating the following Java Code, have a look:

import java.io.PrintStream;
public class test{
public static void main(String[] paramArrayOfString){
System.out.println("Hello world");

Well just by seeing JD perform really well on this simple example,we cannot decide how efficient is this tool. But, still it is a tool thatevery Java Developer must be aware of. Because, in case you have accidently deletedyour Java files and are left with only the .class files, this is the tool that can save your neck.

Like it on Facebook, Tweet it or share this article on other bookmarking websites.

Comments (0)

There are no comments posted here yet

Who will win the UP polls?

It  is going to be battle royale but can Rajiv prove his mettle there?


No answer selected. Please try again.
Please select either existing option or enter your own, however not both.
Please select minimum 0 answer(s) and maximum 5 answer(s).
[{"id":"21442","title":"Congress","votes":"17","type":"x","order":"0","pct":21.52,"resources":[]},{"id":"21443","title":"BJP","votes":"22","type":"x","order":"0","pct":27.85,"resources":[]},{"id":"21444","title":"Mayavati","votes":"12","type":"x","order":"0","pct":15.19,"resources":[]},{"id":"21445","title":"Who cares?","votes":"9","type":"x","order":"0","pct":11.39,"resources":[]},{"id":"21446","title":"Whoever wins, people will lose","votes":"19","type":"x","order":"0","pct":24.05,"resources":[]}] ["#ff5b00","#4ac0f2","#b80028","#eef66c","#60bb22","#b96a9a","#62c2cc"] ["rgba(255,91,0,0.7)","rgba(74,192,242,0.7)","rgba(184,0,40,0.7)","rgba(238,246,108,0.7)","rgba(96,187,34,0.7)","rgba(185,106,154,0.7)","rgba(98,194,204,0.7)"] 350
bottom 200
No married couple wants to end up getting divorced. It is not like they have planned for it. They try to put up with their partners for as long as they
Due to our modern lifestyle, we feel that digestion related disorders are a common problem. Thus, we neither give importance to them nor seek any help
The bond of marriage brings the two people together. Initially, everything may seem okay and both of them slowly start discovering each other in the journey.
Why to choose Java? In the computer market, being able to use Java is a crucial knowledge. Java is a development terminology used to build compelling
DATABASE CONNECTIVITY This articles explains the need of database connectivity, the way it is achieved through Java using the JDBC(java database connectivity)
  Write your first simple java program.   First of all we need is a placewhere we can write your Java code. All Java programs are written using
Array of objects in Java Arrays are defined as block of continous memory locations which are arranged in one after another. Elements of the Array can
Synchronized block is alternative mechanism for "synchronized" methods.If we inherihate the non synchronized blocks either from base class or interface