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 1.6 on a Windows system:
C:\herong>\Progra~1\java\jdk1.6.0_02\bin\java -XX:ThreadStackSize=512
-jar "\Program Files\java\jdk1.6.0_02\demo\jfc\Notepad\notepad.jar"
(Notepad started)
(Start another command window.)
C:\herong>\Progra~1\java\jdk1.6.0_02\bin\jps -l -m
1424 \Program Files\java\jdk1.6.0_02\demo\jfc\Notepad\notepad.jar
3124 sun.tools.jps.Jps -l -m
C:\herong>\Progra~1\java\jdk1.6.0_02\bin\jinfo
-flag ThreadStackSize 1424
-XX:ThreadStackSize=512
C:\herong>\Progra~1\java\jdk1.6.0_02\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?