faqts : Computers : Programming : Languages : Java

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

1 of 2 people (50%) answered Yes
Recently 1 of 2 people (50%) answered Yes

Entry

Java: Disassemble: How to disassemble on the command line? [javap.exe]

Apr 22nd, 2006 09:56
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 22 April 2006 - 04:45 pm ----------------------

Java: Disassemble: How to disassemble on the command line? [javap.exe]

===

To disassemble, run e.g. the program

  javap.exe

===

Steps: Overview:

 1. -Possibly download and install the Sun Java JDK
     (because this installs also the program javap.exe)

 2. -Open an MSDOS box and type the following command
     (the filename without the .class or .java file extension)

      javap.exe <myJavaClassFilename>

       e.g.

        javap.exe HelloWorld

 3. -That will show a screen output similar to the following:

--- cut here: begin --------------------------------------------------

 javad HelloWorldApplet

 Compiled from "HelloWorldApplet.java"

 public class HelloWorldApplet extends java.applet.Applet{

    public HelloWorldApplet();

    public void paint(java.awt.Graphics);

 }

--- cut here: end ----------------------------------------------------

 4. -To compare this output, this was the original Java
     program

--- cut here: begin --------------------------------------------------

 import java.applet.Applet;

 import java.awt.Graphics;

 public class HelloWorldApplet extends Applet {

  public void paint( Graphics g ) {

   g. drawString( "Hello world!", 50, 25 );

  }

 }

--- cut here: end ----------------------------------------------------

 5. -For a list of command line parameters, type

      javap.exe -help

     1. -That will show a screen output similar to the following:

--- cut here: begin --------------------------------------------------

 javap.exe -help

 Usage: javap <options> <classes>...

 where options include:

    -c                        Disassemble the code

    -classpath <pathlist>     Specify where to find user class files

    -extdirs <dirs>           Override location of installed extensions

    -help                     Print this usage message

    -J<flag>                  Pass <flag> directly to the runtime
                              system

    -l                        Print line number and local variable
                              tables

    -public                   Show only public classes and members

    -protected                Show protected/public classes and members

    -package                  Show package/protected/public classes
                              and members (default)

    -private                  Show all classes and members

    -s                        Print internal type signatures

    -bootclasspath <pathlist> Override location of class files loaded
                              by the bootstrap class loader

    -verbose                  Print stack size, number of locals and
                              args for methods If verifying, print
                              reasons for failure

--- cut here: end ----------------------------------------------------

===

Internet: see also:

---



----------------------------------------------------------------------