Looking Up Method Signature with javap Command

This section provides a tutorial example of how to lookup method signatures in a class file or JAR file with the 'javap' command.

"javap" can also be used as a handy tool to look up method signatures while you are writing Java programs.

For example, if you are coding a Java program, and you need to convert a byte array into a character string, but you don't remember which method in the String class to use, and how many arguments are needed for that method. If you are using a good Java IDE, it will help you with a list of public methods and their signatures.

But what can you do, if you are using a simple text editor, not a smart Java IDE? You can use the "javap" command as a handy tool to look up method signatures. The following tutorial example shows you how to find the method to convert a byte array into a character string:

C:\herong>javap java.lang.String | find "byte"

  static final byte LATIN1;
  static final byte UTF16;
  public java.lang.String(byte[], int, int, int);
  public java.lang.String(byte[], int);
  public java.lang.String(byte[], int, int, java.lang.String)
         throws java.io.UnsupportedEncodingException;
  public java.lang.String(byte[], java.lang.String)
         throws java.io.UnsupportedEncodingException;
  public java.lang.String(byte[], int, int);
  public java.lang.String(byte[]);
  public void getBytes(int, int, byte[], int);
  public byte[] getBytes(java.lang.String)
         throws java.io.UnsupportedEncodingException;
  public byte[] getBytes();
  ...

What can you learn from this tutorial example:

Last update: 2018.

Table of Contents

 About This Book

 Java Tools Terminology

 Java Tools Included in JDK

 javac - The Java Program Compiler

 jar - The JAR File Tool

 jlink - The JRE Linker

 jmod - The JMOD File Tool

 jimage - The JIMAGE File Tool

 java - The Java Program Launcher

 jdb - The Java Debugger

 jcmd - The JVM Diagnostic Tool

 jconsole - Java Monitoring and Management Console

 jstat - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jvisualvm (Java VisualVM) - JVM Visual Tool

 jmc - Java Mission Control

javap - The Java Class File Disassembler

 javap - Java Disassembler Command and Options

 javap - Listing Public Variables and Methods

 "javap -private" - Listing Private Variables and Methods

 "javap -c -private" - Disassembling Java Bytecode Class

Looking Up Method Signature with javap Command

 keytool - Public Key Certificate Tool

 jarsigner - JAR File Signer

 jshell - Java Language Shell

 native2ascii - Native-to-ASCII Encoding Converter

 Outdated Tutorials

 References

 Full Version in PDF/EPUB