jinfo - Changing HotSpot VM Option

This section provides a tutorial example on how to set a new value to a HotSpot VM option on a given JVM process using the 'jinfo' tool.

The "jinfo" tool can be used to view the current value of any HotSpot VM option of a given JVM process as described in the previous section.

The "jinfo" tool can also be used set a new value of any HotSpot VM option using the "jinfo -flag name=value" format. Here is what I did to test this function with JDK on a Windows system:

herong> java -XX:MaxHeapSize=123456789 PrimeNumberSeeker 10 200
Period, Current int, # primes
1, 2, 0
2, 10, 4

(Start another command window.)
herong> jps -l -m
12724 jdk.jcmd/sun.tools.jps.Jps -l -m
15412 PrimeNumberSeeker 10 200

(View the current flag value)
herong> jinfo -flag MaxHeapSize 15412

(Change the flag value)
herong> jinfo -flag MaxHeapSize=987654321 15412
Exception in thread "main" com.sun.tools.attach
   flag 'MaxHeapSize' cannot be changed
   at jdk.attach/sun.tools.attach.VirtualMachineImpl.execute(...
   at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.executeCommand(...
   at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.setFlag(...
   at jdk.jcmd/sun.tools.jinfo.JInfo.flag(JInfo.java:142)
   at jdk.jcmd/sun.tools.jinfo.JInfo.main(JInfo.java:123)

Apparently, the target JVM (the PrimeNumberSeeker JVM) does not allow me to change its option. I do not know why.

Table of Contents

 About This Book

 Java Tools Terminology

 Java Tools Included in JDK

 javac - The Java Program Compiler

 java - The Java Program Launcher

 jar - The JAR File Tool

 jlink - The JRE Linker

 jmod - The JMOD File Tool

 jimage - The JIMAGE File Tool

 jpackage - Binary Package Builder

 javadoc - The Java Document Generator

 jdeps - The Java Class Dependency Analyzer

 jdeprscan - The Java Deprecated API Scanner

 jdb - The Java Debugger

 jcmd - The JVM Diagnostic Tool

 jconsole - Java Monitoring and Management Console

 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

 javap - The Java Class File Disassembler

 keytool - Public Key Certificate Tool

 jarsigner - JAR File Signer

 jshell - Java Language Shell

 jrunscript - Script Code Shell

 Miscellaneous Tools

 native2ascii - Native-to-ASCII Encoding Converter

 JAB (Java Access Bridge) for Windows

 Archived Tutorials


 Full Version in PDF/EPUB