HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
1. Feel Free to ask and submit anything on and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
3. Our Experts are looking for yours ?.

java-compiler: How to convert class file in java source code?

I have one .class file, i want to see the java source code for that file. Please give me an example to convert that class file in java source code.

java x 211
compiler x 5
Posted On : 2016-04-23 17:57:40.0
profile Rishi Kumar - Rishi Kumar


is a library that reconstructs Java source code from one or more ".class" files. JD-Core may be used to recover lost source code and explore the source of Java runtime libraries. New features of Java 5, such as annotations, generics or type "enum", are supported. JD-GUI and JD-Eclipse include JD-Core library.

is a standalone graphical utility that displays Java source codes of ".class" files. You can browse the reconstructed source code with the JD-GUI for instant access to methods and fields.

is a plug-in for the Eclipse platform. It allows you to display all the Java sources during your debugging process, even if you do not have them all.

is a plug-in for... the IntilliJ IDE.

Let´s see very simple example using JD-core library. To download JD-Core library for windows- click her. This zip file contains two files:

1. jad.exe
2. Readme.txt

Unzip file into any appropriate directory on your hard drive. I extracted it on Desktop in folder. I just created very simple java file that is
class A
public static void main(String s1[])

Just using javac tool I got .class file and placed it into folder located on Desktop. Now open command prompt and point the folder containing jad.exe file and .class file like below:

C:\Users\Anyforum\Desktop\>jad A.class
Parsing A.class... Generating A.jad

Open newly generated .jad file in notepad. Let´s see what i got for above java file:

// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page:
// Decompiler options: packimports(3)
// Source File Name:


class A


public static void main(String args[])

So .jad file contains the valid source code, It might not be same as you write in java file because java compiler adds something in .class file as you can see in above example "default constructor"(if you don´t write any constructor in java file compiler adds default constructor by itself). If you want to generate .java file use below command:

C:\Users\Anyforum\Desktop\>jad -sjava A.class
Parsing A.class... Generating

It´ll generate file containing the java source code of A.class file. Refer Readme.txt file for more control or help command.

Posted On : 2016-04-23 18:38:34
Satisfied : 1 Yes  0 No
profile Garima Gupta - Garima Gupta
Reply This Thread

Post Answer
Please Login First to Post Answer: Login login with facebook -