{

What is the use of javap command in java?


javap is the tool provided by the java language which was bundled with JDK software. javap tool is located in the JAVA\_HOME\\bin location which is used by many Java developers to find the member variables and methods for any Java object.

It also has an option to provide byte code of a java class

Syntax

javap Options Classes  

Classes: single or multiple classes with the complete package name, for example, java.lang.Object instead of Object.

Options: there are command-line options to control configurations.

Options

Options Description
-help command line usage information
-v version information
-public Displays only public class and members
-protected Displays only public and protected class and members
-package Displays all class and members in a package
-constants Displays constants
-classpath path to find the classes
-sysinfo Displays information like size, date, and hash

Here is an javap command output for java.util.List

javap command in java

We can also use -c options with the javap command to compile the source code and display the information about the object

Javap command example

Here is an example of javap command result for java.lang.Object

B:\javaproject>javap java.lang.Object
Compiled from "Object.java"
public class java.lang.Object {
  public java.lang.Object();
  public final native java.lang.Class<?> getClass();
  public native int hashCode();
  public boolean equals(java.lang.Object);
  protected native java.lang.Object clone() throws java.lang.CloneNotSupportedException;
  public java.lang.String toString();
  public final native void notify();
  public final native void notifyAll();
  public final native void wait(long) throws java.lang.InterruptedException;
  public final void wait(long, int) throws java.lang.InterruptedException;
  public final void wait() throws java.lang.InterruptedException;
  protected void finalize() throws java.lang.Throwable;
  static {};
}
THE BEST NEWSLETTER ANYWHERE
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
Subscribe
You'll get a notification every time a post gets published here.