To Disassemble a class file in Java there is a tool called javap. This Disassembling tool prints outs the details of the class like, methods, package, protected, public. When you wish to disassemble any class of java. first compile them using javac then call the javap Class Name.Consider the example given below
DisassesmleExample.java
public class DisassesmleExample {
public int add(int x, int y) {
return x + y;
}
public int substract(int x, int y) {
return x - y;
}
public int multiply(int x, int y) {
return x * y;
}
}
Now Compile the aboove class using javac
C:\Java Test>javac DisassesmleExample.java
Now run it using javap as
C:\Java Test>javap DisassesmleExample
Compiled from "DisassesmleExample.java"
public class DisassesmleExample extends java.lang.Object{
public DisassesmleExample();
public int add(int, int);
public int substract(int, int);
public int multiply(int, int);
}
There are many available with this disassembler tool they are. For example if you use javap -c DisassesmleExample. This will disassemble all the code, -l it will print line number and local variable. with -package It will show package/ public/protected classes and members. To see more option open your command prompt go to the java/bin directory and then type javap - help it will print all the option of javap.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Disassembling Java Classes - Java Tutorials
Post your Comment