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

OptionsDescription
-helpcommand line usage information
-vversion information
-publicDisplays only public class and members
-protectedDisplays only public and protected class and members
-packageDisplays all class and members in a package
-constantsDisplays constants
-classpathpath to find the classes
-sysinfoDisplays 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 {};
}