Java Tools Tutorials - Herong's Tutorial Notes - Version 5.30, by Dr. Herong Yang

Changing HotSpot VM Option using 'jinfo'

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:

C:\herong>\Progra~1\java\jdk1.8.0\bin\java -XX:ThreadStackSize=512
   -jar "\Program Files\java\jdk1.8.0\demo\jfc\Notepad\notepad.jar"
   (Notepad started)


(Start another command window.)
C:\herong>\Progra~1\java\jdk1.8.0\bin\jps -l -m

1424 \Program Files\java\jdk1.8.0\demo\jfc\Notepad\notepad.jar
3124 sun.tools.jps.Jps -l -m


C:\herong>\Progra~1\java\jdk1.8.0\bin\jinfo 
   -flag ThreadStackSize 1424

-XX:ThreadStackSize=512


C:\herong>\Progra~1\java\jdk1.8.0\bin\jinfo 
   -flag ThreadStackSize=1024 1424
   
Exception in thread "main" java.io.IOException: 
   Command failed in target VM
   at sun.tools.attach.WindowsVirtualMachine.execute
      (WindowsVirtualMachine.java:94)
   at sun.tools.attach.HotSpotVirtualMachine.executeCommand
      (HotSpotVirtualMachine.java:195)
   at sun.tools.attach.HotSpotVirtualMachine.setFlag
      (HotSpotVirtualMachine.java:172)
   at sun.tools.jinfo.JInfo.flag(JInfo.java:105)
   at sun.tools.jinfo.JInfo.main(JInfo.java:58)

Apparently, the target VM (the Notepad VM) does not allow me to change its option. I do not know why?

Table of Contents

 About This Book

 Java Tools Terminology

 Installing Java 8 on Windows

 'javac' - The Java Program Compiler

 'java' - The Java Program Launcher

 'jdb' - The Java Debugger

 'jconsole' - Java Monitoring and Management Console

 'jstat' - JVM Statistics Monitoring Tool

JVM Troubleshooting Tools

 JVM Troubleshooting Tools in JDK 1.5

 'jinfo' - VM Option Value Checker

Changing HotSpot VM Option using 'jinfo'

 'jstack' - Stack Tracer of JVM Threads

 Java Thread Deadlock Demo Program

 Detecting Java Thread Deadlocks with 'jstack'

 'jmap' - JVM Heap Dump Tool

 Printing Histogram of Java Object Heap

 Generating Heap Dump File with 'jmap'

 'jhat' - Java Heap Analysis Tool

 Starting 'jhat' 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

 jvisualvm (Java VisualVM) - JVM Visual Tool

 'jar' - The JAR File Tool

 'javap' - The Java Class File Disassembler

 'keytool' - Public Key Certificate Tool

 'native2ascii' - Native-to-ASCII Encoding Converter

 Outdated Tutorials

 References

 PDF Printing Version

Changing HotSpot VM Option using 'jinfo' - Updated in 2014, by Dr. Herong Yang