banner



How To Open Class File In Windows 10

javap is the Java Disassembler tool which can exist used to open a .form file in a readable format.javap is located in the /bin binder of the JDK installation directory. TheCoffee Decomplier (javap) displays data about thepackage, protected and public fields, and methods of the classes passed to it. The javap tool prints its output to stdout. In this article lets learn how to open up a .course file in java with Example using javap.

Syntax for Javap

                javap <<pick>> <<.course file1>> <<.form file2>>              

Javap Command Example in Java

lets employ the Java Decomplier (Javap tool) to decompile our Demo grade.

Demo.coffee

package com.javainterviewpoint;  public class Demo  {     public void disp()     {         Organization.out.println("Welcome to JavaInterviewPoint!!!");     }     public static void main(String args[])     {         Demo d1 = new Demo();         d1.disp();     } }

Output :

upon executing javap control in cmd

javap com.javainterviewpoint.Demo

The below output volition be produced

C:\JIP>javap com.javainterviewpoint.Demo Compiled from "Demo.java" public course com.javainterviewpoint.Demo {   public com.javainterviewpoint.Demo();   public void disp();   public static void main(java.lang.Cord[]); }              

In the above code we have not used whatsoever options along with javap command in cmd, the most popular option is '-c', this pick prints instructions that contain the Coffee bytecodes for each of the methods in the class.

C:\JIP>javap -c com.javainterviewpoint.Demo Compiled from "Demo.coffee" public class com.javainterviewpoint.Demo {   public com.javainterviewpoint.Demo();     Code:        0: aload_0        1: invokespecial #1                  // Method java/lang/Object."":()5        four: return    public void disp();     Code:        0: getstatic     #2                  // Field coffee/lang/System.out:Ljava/io/PrintStream;        three: ldc           #3                  // String Welcome to JavaInterviewPoint!!!        5: invokevirtual #4                  // Method java/io/PrintStream.println:(Ljava/lang/Cord;)5        8: return    public static void main(java.lang.String[]);     Lawmaking:        0: new           #5                  // class com/javainterviewpoint/Demo        3: dup        4: invokespecial #6                  // Method "":()V        7: astore_1        viii: aload_1        9: invokevirtual #7                  // Method disp:()V       12: return }

How to use Javap control in Eclipse

Running javap command in eclipse can be done using External Tool Configuration only.  Goto "Run –> External Tools –> External Tools Configurations" equally shown in below image.

Eclipse External Tools Configuration

Enter the below information in the new Configuration window

  1. Click on Programme and click on New
  2. Give the name for the configuration, here we have given'javap -verbose'
  3. Select the Location of javap.exe, past browsing the file system. Usually javap.exe will exist location in the<<jdk installation>>/bin directory
  4. Select the Working Directory, the location where the form file resides (Demo Class). Click on scan workspace nether bin select the package under where Demo class resides (Here com/javainterviewpoint)
  5. In the Arguments block requite -verbose Demo , where -verbose is the option which yous want to execute along with javap and Demo is our class proper name.
  6. Click on Apply and Finally Run.

javap command eclipse configuration

Nosotros will become the beneath out displayed

Classfile /C:/Jackson/EclipseKepler/Workspace/MyJava/bin/com/javainterviewpoint/Demo.course   Concluding modified Feb v, 2016; size 696 bytes   MD5 checksum ed681f968119b07f83eadbed004dcbee   Compiled from "Demo.coffee" public course com.javainterviewpoint.Demo   SourceFile: "Demo.java"   modest version: 0   major version: 51   flags: ACC_PUBLIC, ACC_SUPER  Abiding puddle:    #1 = Class              #2             //  com/javainterviewpoint/Demo    #2 = Utf8               com/javainterviewpoint/Demo    #iii = Class              #4             //  java/lang/Object    #4 = Utf8               java/lang/Object    #5 = Utf8                   #6 = Utf8               ()V    #7 = Utf8               Code    #eight = Methodref          #3.#9          //  java/lang/Object."":()V    #nine = NameAndType        #v:#6          //  "":()V   #10 = Utf8               LineNumberTable   #xi = Utf8               LocalVariableTable   #12 = Utf8               this   #xiii = Utf8               Lcom/javainterviewpoint/Demo;   #xiv = Utf8               disp   #xv = Fieldref           #sixteen.#eighteen        //  java/lang/System.out:Ljava/io/PrintStream;   #xvi = Class              #17            //  java/lang/System   #17 = Utf8               java/lang/Organisation   #18 = NameAndType        #19:#20        //  out:Ljava/io/PrintStream;   #xix = Utf8               out   #20 = Utf8               Ljava/io/PrintStream;   #21 = Cord             #22            //  Welcome to JavaInterviewPoint!!!   #22 = Utf8               Welcome to JavaInterviewPoint!!!   #23 = Methodref          #24.#26        //  java/io/PrintStream.println:(Ljava/lang/String;)V   #24 = Class              #25            //  java/io/PrintStream   #25 = Utf8               java/io/PrintStream   #26 = NameAndType        #27:#28        //  println:(Ljava/lang/String;)5   #27 = Utf8               println   #28 = Utf8               (Ljava/lang/String;)V   #29 = Utf8               main   #30 = Utf8               ([Ljava/lang/Cord;)V   #31 = Methodref          #1.#9          //  com/javainterviewpoint/Demo."":()V   #32 = Methodref          #i.#33         //  com/javainterviewpoint/Demo.disp:()5   #33 = NameAndType        #14:#half-dozen         //  disp:()Five   #34 = Utf8               args   #35 = Utf8               [Ljava/lang/String;   #36 = Utf8               d1   #37 = Utf8               SourceFile   #38 = Utf8               Demo.java {   public com.javainterviewpoint.Demo();     flags: ACC_PUBLIC      Lawmaking:       stack=1, locals=1, args_size=one          0: aload_0                 1: invokespecial #8                  // Method java/lang/Object."":()V          iv: return               LineNumberTable:         line 3: 0       LocalVariableTable:         Start  Length  Slot  Name   Signature                0       5     0  this   Lcom/javainterviewpoint/Demo;    public void disp();     flags: ACC_PUBLIC      Code:       stack=2, locals=1, args_size=ane          0: getstatic     #15                 // Field java/lang/System.out:Ljava/io/PrintStream;          3: ldc           #21                 // String Welcome to JavaInterviewPoint!!!          5: invokevirtual #23                 // Method java/io/PrintStream.println:(Ljava/lang/String;)V          8: return               LineNumberTable:         line 7: 0         line viii: 8       LocalVariableTable:         Beginning  Length  Slot  Proper name   Signature                0       ix     0  this   Lcom/javainterviewpoint/Demo;    public static void main(java.lang.String[]);     flags: ACC_PUBLIC, ACC_STATIC      Code:       stack=2, locals=2, args_size=1          0: new           #1                  // class com/javainterviewpoint/Demo          3: dup                     4: invokespecial #31                 // Method "":()Five          7: astore_1                8: aload_1                 9: invokevirtual #32                 // Method disp:()V         12: return               LineNumberTable:         line 11: 0         line 12: 8         line 13: 12       LocalVariableTable:         Commencement  Length  Slot  Name   Signature                0      13     0  args   [Ljava/lang/String;                8       5     1    d1   Lcom/javainterviewpoint/Demo; }

you tin can as well add dissimilar options in the Arguments block for unlike output. The complete listing of the option which can be used along with Java Disassembler is nowadays here.

Happy Learning !!:)

Source: https://www.javainterviewpoint.com/how-to-open-class-file-in-java/

Posted by: gingrichlailes.blogspot.com

0 Response to "How To Open Class File In Windows 10"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel