Hi
Anyone know the steps to convert the class file back to the original java file..
Say i have one file call example.class..
Thanks
Printable View
Hi
Anyone know the steps to convert the class file back to the original java file..
Say i have one file call example.class..
Thanks
I don't understand your question. Are you wanting to do something equivilant to undo? I mean, did you mess up and accidently compile? You could just delete the class file and recompile or something.
I heard from my friends that i could use some methods to get back from the classes file back to the .java files...
but they are not sure how to convert back.....indeed it can be done..
I know i can re-compile the java file to get back the class but....
I am curious and want to learn new thing so i just try but don't know the steps to start it...
Are you talking about decompiling?
Quote:
Originally Posted by toytoy
I've heard about this too, but I really don't know how. Maybe someone else does. Anyways I'll try researching it, and see what I can find.
You can use the DJ program, it works quite well, although your comments and layout will be gone, as those aren't stored in the class files.
http://members.fortunecity.com/neshkov/dj.html
There is a built in decompiler called javap. For instance if you want to decompile a .class file named Search you would do the following at the command line. C:\jdk1.5.0\bin> javap -classpath C:\; Search.class
You will notice that if you run the decompiler on a .class file the output will have no implementation. Running C:\jdk1.5.0\bin> javap -classpath C:\; D on the code below will give you the following. If you want to get the disassembled code, i.e., the instructions that comprise the Java bytecodes then you can run javap with the -c switch C:\jdk1.5.0\bin> javap -c -classpath C:\; D
Code:public class D extends java.lang.Object{
public D();
public static void main(java.lang.String[]);
}
Code:class DeTest{
private String greeting = "Hello";
public void changeGreeting(String greeting){
this.greeting = greeting;
}
public void printGreeting(){
System.out.println(greeting);
}
}
public class D{
public static void main(String[] args){
DeTest dt = new DeTest();
dt.printGreeting();
dt.changeGreeting("Goodbye");
dt.printGreeting();
}
}