Java Tools Tutorials - Herong's Tutorial Examples - v6.23, by Herong Yang
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 -XX:MaxHeapSize=123731968 (Change the flag value) herong> jinfo -flag MaxHeapSize=987654321 15412 Exception in thread "main" com.sun.tools.attach .AttachOperationFailedException: 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
javac - The Java Program Compiler
java - The Java Program Launcher
jpackage - Binary Package Builder
javadoc - The Java Document Generator
jdeps - The Java Class Dependency Analyzer
jdeprscan - The Java Deprecated API Scanner
jcmd - The JVM Diagnostic Tool
jconsole - Java Monitoring and Management Console
jstat - JVM Statistics Monitoring Tool
JVM Troubleshooting Tools in JDK
jinfo - VM Option Value Checker
►jinfo - Changing HotSpot VM Option
jstack - Stack Tracer to Generate Thread Dump
Java Thread Deadlock Demo Program
jstack - Detecting Java Thread Deadlocks
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
Searching for Instances with OQL Statements
jhsdb - The Java HotSpot Debugger
jvisualvm (Java VisualVM) - JVM Visual Tool
javap - The Java Class File Disassembler
keytool - Public Key Certificate Tool
jrunscript - Script Code Shell
native2ascii - Native-to-ASCII Encoding Converter