"javap" - Dedault Output

Q

What Is the default output of the "javap" Command?

✍: FYIcenter

A

The default output of the "javap" command presents the interface information of the Java class stored in the given bytecode.

1. Create a Java class, HelloWorldFrame.java, with the following source code,

import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class HelloWorldFrame extends JFrame {
  String message = "Hello World!";

  public HelloWorldFrame(){
    setContentPane(new JPanel(){
      @Override
      protected void paintComponent(Graphics g) {
        g.drawString(message, 15, 30);
      }
    });
    setSize(100, 100);
  }
  public static void main(String[] args) {
    HelloWorldFrame frame = new HelloWorldFrame();
    frame.setVisible(true);
  }
}

2. Compile it into a bytecode file, HelloWorldFrame.class:

> javac HelloWorldFrame.java 

3. Disassemble it using "javap" command with default options

> javap HelloWorldFrame.class 

Compiled from "HelloWorldFrame.java"
public class HelloWorldFrame extends javax.swing.JFrame {
  java.lang.String message;
  public HelloWorldFrame();
  public static void main(java.lang.String[]);
}

 

"javap -c" - Generate Assembler Instructions

What Is JDK "javap" Command

JDK "javap" Command

⇑⇑ Java Bytecode Tools

2021-08-21, 698🔥, 0💬