Java Tools Tutorials - Herong's Tutorial Examples

https://www.herongyang.com/Java-Tools

Copyright © 2005-2023 Herong Yang. All rights reserved.

Java Tools Tutorials This tutorial book based on notes and sample codes collected by the author while he was learning Java tools himself. Topics includes: 'java/javaw' Launcher, 'javac' Compiler, 'javadoc' Document Generator, 'javap' Class File Disassembler, 'jar/jarsigner' Archive Tool, 'jconsole' Console, 'jdb' Debugger, 'jdeps' Dependency Analyzer, 'jdeprscan' Deprecated API Scanner, 'jhat' Heap Analysis Tool, 'jlink' JRE Linker, 'jhsdb' HotSpot Debugger, 'jmap' Memory Dumper, 'jmc' Mission Control, 'jpackage' Binary Package Builder, 'jrunscript' Script Shell, 'jstack' Stack Dumper, 'jstat' Statistics, 'jstatd' Statistics Daemon, 'jvisualvm' Visual VM, 'jwebserver' Web Server, 'keytool' Keystore Tool, 'serialver' serialVersionUID generator. Updated in 2023 (Version v6.23) with JDK 20.

Table of Contents

About This Book

Java Tools Terminology

Java Tools Included in JDK

Installing Latest JDK on macOS

Installing Latest JDK on Windows

Adding JDK "bin" Direcotry to Path Setting

Testing JDK Installation

Listing Java Tools in JDK

javac - The Java Program Compiler

javac - Java Compilation Command and Options

Compiling Hello.java - My First Java Program

"javac -classpath" - Specifying Class Path

"javac -verbose" - Printing Compilation Details

"javac -sourcepath" - Specifying Source Path

"javac -d" - Specifying Output Directory

Two Types of "import" Statements

"import" Statements Processed by "javac"

"javac -g" - Controlling Debugging Information

"javac --module" - Compiling Entire Module

"javac -X" - Specifying Non-Standard Options

java - The Java Program Launcher

java - Program Launching Command and Options

Launching Hello.java - My First Java Program

"java -classpath" - Specifying Class Path

"java -jar" - Specifying Executable JAR File

"java -X" - Specifying Non-Standard Options

"java --list-modules" - Listing Modules in JDK

"java --describe-module" - Printing Module Definition

"java --module" - Launching Program from Module

"java --module" - Launching Program from Module JAR

javaw - Launching Java Programs without Console

jar - The JAR File Tool

JAR - Java Archive File Format

jar - JAR File Tool Command and Options

"jar --create" - Creating New JAR File

"jar --list" - Listing Files in JAR File

"jar --extract" - Extracting Files from JAR File

Managing JAR Files with WinZIP

META-INF/MANIFEST.MF - JAR Manifest File

Adding META-INF/MANIFEST.MF to JAR Files

"jar -C" - Changing Input Directory

Using JAR Files in Java Class Paths

"jar --update" - Updating Class Files in JAR

"jar --main-class" - Making JAR File Executable

Creating Module JAR File

"jar --module-version" - Updating Module Version in JAR

jlink - The JRE Linker

jmod - The JMOD File Tool

jimage - The JIMAGE File Tool

JIMAGE - Java Image File Format

jimage - JIMAGE File Tool Command

"jimage info|list" - Listing JIMAGE Entries

"jimage extract" - Extracting JIMAGE File Entries

Java File Types and Related Tools

jpackage - Binary Package Builder

jpackage - What Is It

"jpackage -t dmg" - Package for macOS

"jpackage -t pkg" - Package for macOS

"jpackage -t msi" - Package for Windows

javadoc - The Java Document Generator

javadoc - Document Generator Command and Options

Hello.java API Document

HelloDocumented.java - javadoc-Style Comments

Generate API Document for Java Package

jdeps - The Java Class Dependency Analyzer

jdeps - Class Dependency Analyzer Command

"jdeps class_file" - Dependencies of Class File

"jdeps -verbose" - Class Level Dependencies of Class File

"jdeps jar_file" - Dependencies of JAR File

"jdeps --inverse --require ..." - Reverse Dependencies

jdeprscan - The Java Deprecated API Scanner

jdeprscan - Deprecated API Scanner Command

"jdeprscan jar_file" - Deprecated API of Class File

"jdeprscan jar_file" - Deprecated API of JAR File

"jdeprscan --release X" - Deprecated API as of Release X

"jdeprscan --list" - List All Deprecated APIs

jdb - The Java Debugger

jcmd - The JVM Diagnostic Tool

jcmd - JVM Diagnostic Tool Command

"jcmd 0 help" - Listing JVM Diagnostic Commands

"jcmd 0 VM.*" - Running VM Diagnostic Commands

"jcmd 0 GC.*" - Running GC Diagnostic Commands

"jcmd 0 Thread.print" - Generating Thread Dump

jconsole - Java Monitoring and Management Console

JMX Technology and jconsole Tool

jconsole - Command Options and Connection Window

com.sun.management.jmxremote - JMX Agent for Local Connection

jconsole - Connecting to a Local JMX Agent

com.sun.management.jmxremote.port - JMX Agent for Remote Connection

jconsole - Connecting to a Remote JMX Agent

jstat - JVM Statistics Monitoring Tool

JVM Troubleshooting Tools

JVM Troubleshooting Tools in JDK

jinfo - VM Option Value Checker

jinfo - Changing HotSpot VM Option

jstack - Stack Tracer to Generate Thread Dump

What Is a Thread Dump?

Java Thread Deadlock Demo Program

jstack - Detecting Java Thread Deadlocks

jmap - JVM Heap Dump Tool

Printing Histogram of Java Object Heap

jmap - Generating Heap Dump File

jhat - Java Heap Analysis Tool

jhat - Starting Web Server on a Heap Dump File

Listing Instance Counts of All Classes

Browsing Object Instance Values

Object Query Language (OQL)

Searching for Instances with OQL Statements

jhsdb - The Java HotSpot Debugger

jvisualvm (Java VisualVM) - JVM Visual Tool

jmc - Java Mission Control

jmc (Java Mission Control) - What Is It

Launching jmc (Java Mission Control)

jmc - JMX Console via MBean Server

MBean Browser on jmc JMX Console

Monitoring Trigers on jmc JMX Console

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

jshell - What Is It

jshell - Entering Expressions and Statements

"jshell> /save" - Saving Code Snippet

"jshell> /edit" - Editing Code Snippet

jrunscript - Script Code Shell

jrunscript - What Is It

"jrunscript" - Run JavaScript Interactively

"jrunscript -f" - Run JavaScript in Batch Mode

Miscellaneous Tools

serialver - serialVersionUID Generator

jaotc - Java Ahead-Of-Time Compiler

jwebserver - Java Web Server

native2ascii - Native-to-ASCII Encoding Converter

native2ascii - Encoding Converter Command and Options

javac - Using CP1252 to Process Source File

"native2ascii -encoding" - UTF-8 to uXXXX Conversion

Setting UTF-8 Encoding in PrintStream

Converting uXXXX Sequences Back with "-reverse" Option

JAB (Java Access Bridge) for Windows

What Is JAB (Java Access Bridge)

Java GUI Test Program

"jaccesswalker" - GUI Component Tree Browser

"jaccessinspector" - Accessible Information Examiner

Archived Tutorials

Installing JDK 15 on macOS

Archived: Installing JDK 12 on Windows

Archived: Installing JDK 10 on Windows

Archived: Downloading and Installing Java 8

Archived: Downloading and Installing J2SE 1.6.0 on Windows

Archived: JDK 1.6 keytool - keystore File Tool

Archived: Downloading and Installing J2SE 1.5.0 on Windows

Archived: JDK 1.5 keytool - keystore File Tool

References

Full Version in PDF/EPUB

Keywords: Java, Tools, Compiler, Debugger, Monitor