JVM Tutorials - Herong's Tutorial Examples


Copyright © 1997-2024 Herong Yang. All rights reserved.

JVM Tutorials This book is a collection of notes and sample codes written by the author while he was learning JVM himself. Topics include JVM (Java Virtual Machine) Architecture and Components; Oracle JVM implementation - HotSpot; Eclipse JVM implementation - Eclipse OpenJ9; java.lang.Runtime - The JVM Instance class; Loading Native Libraries; java.lang.System - Representing Operating System; java.lang.ClassLoader - Loading class files; java.lang.Class - Class reflections; Runtime data areas, heap memory and Garbage Collection; Stack, Frame and Stack overflow; Multi-threading impacts on CPU and I/O; CDS (Class Data Sharing); Micro Benchmark tests on different types of operations. Updated in 2024 (Version v5.13) with HotSpot JVM 20.

Table of Contents

About This Book

JVM (Java Virtual Machine) Specification

What Is JVM (Java Virtual Machine)

What Is JVM Specification

JVM Architectures and Components

Implementations of JVM Specification

Java HotSpot VM - JVM by Oracle/Sun

What Is HotSpot JVM

Download and Install JDK on macOS

Download and Install JDK on Windows

Running Java HotSpot Client VM

Running Java HotSpot Server VM

HotSpot Memory Usages on Windows Systems

java.lang.Runtime Class - The JVM Instance

What Is Runtime?

Printing Runtime Basic Information

Running the Garbage Collector Explicitly

Shutting Down or Terminating the JVM Instance

Executing System Commands

Loading Native Libraries

java.lang.System Class - The Operating System

What Is java.lang.System

Standard Input, Output, and Error Streams

Current Time in Milliseconds and Nanoseconds

Accessing System Environment Variables

Getting and Adding System Properties

ClassLoader Class - Class Loaders

What Is Class Loader

What Is java.lang.ClassLoader Class

Accessing the ClassLoader of a Class

JVM "-verbose:class" Option

loadClass() Method - Loading Classes Explicitly

getSystemResource() Method - Finding Files

Class Loading Problem - JAR Hell

ClassChecker.java - Reports Class Loader

ClassChecker.java - Reports Class Locations

"superclass access check failed" Class Load Error

Class Loading Followed by Class Initialization

Class Class - Class Reflections

What Is java.lang.Class Class

forName() Method - Loading Classes

Class Reflection and Introspection

Array Class Introspection

Invoking Methods of Class Instances

JVM Runtime Data Areas

JVM Stack, Frame and Stack Overflow

Thread Testing Program and Result

CrashThread2.java - Thread Testing Program

Thread Test on HotSpot JVM 10

Thread Test on HotSpot 1.7

Thread Test on JRockit 28.7

Thread Test on HotSpot 1.4 and JRockit 7.0

Thread Test on HotSpot 1.6

CPU Impact of Multi-Thread Applications

I/O Impact of Multi-Thread Applications

CDS (Class Data Sharing)

Micro Benchmark Runner and JVM Options

What Is Micro Benchmark?

BenchmarkRunner.java - Benchmark Runner Program

emptyLoop() - The Empty Loop Test Method

"-XX:+PrintCompilation" - Watching JIT Compilation Logs

"-XX:+PrintGC" - Watching GC (Garbage Collection) Logs

"-Xms" and "-Xmx" - Avoiding GC with Large Memory Size

Benchmark Affected by Other Running Applications

"-Xint" - Running in Interpreted-Only Mode

Micro Benchmark Tests on "int" Operations

Micro Benchmark Tests on "long" Operations

Micro Benchmark Tests in JIT Compilation Mode

Micro Benchmark Tests on "float" and "double" Operations

OpenJ9 by Eclipse Foundation

What Is Eclipse OpenJ9

Install OpenJ9 JVM with OpenJDK on CentOS Systems

Footprint Comparison - OpenJ9 vs. HotSpot

Startup Time Comparison - OpenJ9 vs. HotSpot

JRockit JVM 28.2.7 by Oracle Corporation

What Is JRockit JVM?

Downloading and Installing JRockit R28.2.7

Running Java Programs on JRockit R28.2.7

Memory Footprint of JRockit R28.2.7

What Is JRockit Mission Control?

Running JRockit Mission Control

What JRockit Management Console

JRockit Management Console on HotSpot JVM

Archived Tutorials

archived: Download and Install JDK 14 on macOS

Archived: Download and Install Latest JDK 10 on Windows

Archived: Download and Install JDK 1.8.0 on Windows

Archived: Download and Install JDK 1.7.0 on Windows

Archived: Download and Install Java SE 1.6 Update 2

Archived: Installing JRockit JVM 8.0

Archived: Testing with LongWhile.java

Archived: Testing with LongSleep.java

Archived: GCTest.java - Garbage Collection Test Program

Archived: GC Test - Constant Memory Requirement

Archived: GC Test - Periodical Memory Requirement

Archived: GC Test - Releasing Old vs. New Objects

Archived: GC Test - JDK 1.4.0 vs. JDK 1.3.1

Archived: GC Test - Client vs. Server

Archived: StringBuffer Testing Program

Archived: Installing JRockit JVM 7.0

Archived: Running JRockit JVM with Management Console


Full Version in PDF/EPUB

Keywords: JVM, Java, Virtual, Machine