Tuesday 25 March 2014

Decompile Java Class File Using Decompilers.

Posted By: Unknown - Tuesday, March 25, 2014

duke-java-mascot


Byte codes generated by javac compiler can again be converted into java source. For this we need a decompiler tool. Decompilers are the utilities that generate the source code from input java class file.
A Decompiler knows about the structure of a Java class and parse it to generated Java source code.
Java decompilers will not give the exact Java source file from which class was generated and executed by Java Virtual Machine. But most of the structure will be maintained.

JAD: Java Decompiler

A lot of Decompilers are available in the market to decompile a class file. We will use one of the free decomipler called JAD.
You can download JAD compiler from hereUpdate: JAD’s site is down hence you can download it from this link.
I have used a simple Hello World java class to demonstrate JAD decompiler. Following is the code of HelloWorld.java file.
public class HelloWorld {
    public static void main(String args[]) {
        String fooBar = "Hello World from Java.";
        System.out.println(fooBar);
    }
}
Use following output when we use command line utility JAD to decompile our class file.
$> jad HelloWorld.class
Parsing HelloWorld.class... Generating HelloWorld.jad
The source file output of JAD is in file with .jad extension. You can change the extension to .java.
Following is the source that you get after decompillng our HelloWorld.class file.
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: HelloWorld.java
import java.io.PrintStream;
public class HelloWorld
{
public HelloWorld()
{
}
public static void main(String args[])
{
String s = "Hello World from Java.";
System.out.println(s);
}
}
Note that the string variable that we used in our original Java class was fooBar and it got changed intos.

0 comments:

Post a Comment

this blog is helpful or not

International

Auto News

Translate

Pages

Popular Posts

Popular Posts

Designed By Templatezy / Sb Game Hacker Apk / MyBloggerThemes