1 jinfo(Configuration Info forJava)作用
实时地查看和调整虚拟机各项参数
2 命令格式
jinfo [options]
参数解释:
第一个参数:options
- no option:输出全部的参数和系统属性
- -flag name:输出对应名称的参数
- -flag [+|-]name:开启或者关闭对应名称的参数
- -flag name=value:设定对应名称的参数
- -flags:输出全部的参数
- -sysprops:输出系统属性
3 命令演示
代码如下:
package com.example.demo;import java.io.IOException;/*jinfo:命令:jinfo pid描述:输出当前 jvm 进程的全部参数和系统属性命令:jinfo -flags pid描述:输出全部的虚拟机参数命令:jinfo -sysprops pid描述:输出当前虚拟机进程的全部的系统属性命令:jinfo -flag name pid描述:使用该命令,可以查看指定的 jvm 参数的值如:查看当前 jvm 进程是否开启打印 GC 日志jinfo -flag PrintGC pid命令:jinfo -flag [+|-]name pid描述:开启或者关闭对应名称的参数使用 jinfo 可以在不重启虚拟机的情况下,可以动态的修改 jvm 的参数。尤其在线上的环境特别有用。jinfo -flag +PrintGC pidjinfo -flag PrintGC pidjinfo -flag +PrintGC pidjinfo -flag PrintGC pid命令:jinfo -flag name=value pid描述:修改指定参数的值。和上面的例子相似,但是上面的主要是针对 boolean 值的参数设置的。如果是设置 value值,则需要使用 name=value 的形式jinfo -flag HeapDumpPath pidjinfo -flag HeapDumpPath=d:\\dump pidjinfo -flag HeapDumpPath pidjinfo -flag HeapDumpPath= pidjinfo -flag HeapDumpPath pid注意:jinfo虽然可以在java程序运行时动态地修改虚拟机参数,但并不是所有的参数都支持动态修改*/
public class jinfodemo01 {public static void main(String[] args) throws IOException {System.out.println("jinfo");System.in.read();}
}
运行后进入命令行工具输入命令。
(1)命令一
jinfo pid
描述:输出当前 jvm 进程的全部参数和系统属性
结果如下:
Attaching to process ID 14784, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.261-b12
Java System Properties:java.runtime.name = Java(TM) SE Runtime Environment
java.vm.version = 25.261-b12
sun.boot.library.path = C:\Program Files\Java\jdk1.8.0_261\jre\bin
java.vendor.url = http://java.oracle.com/
java.vm.vendor = Oracle Corporation
path.separator = ;
file.encoding.pkg = sun.io
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
sun.os.patch.level =
sun.java.launcher = SUN_STANDARD
user.script =
user.country = CN
user.dir = H:\project\jvmtestdemo
java.vm.specification.name = Java Virtual Machine Specification
java.runtime.version = 1.8.0_261-b12
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
os.arch = amd64
java.endorsed.dirs = C:\Program Files\Java\jdk1.8.0_261\jre\lib\endorsed
line.separator =java.io.tmpdir = C:\Users\XIONGP~1\AppData\Local\Temp\
java.vm.specification.vendor = Oracle Corporation
user.variant =
os.name = Windows 10
sun.jnu.encoding = GBK
java.library.path = C:\Program Files\Java\jdk1.8.0_261\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files (x86)\Common Files\Oracle
\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program
Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;E:\maven\apache-maven-3.6.1\bin;E:\maven\apache-maven-3.6.1\bin;D:\Program Files\apac
he-tomcat-9.0.37\lib;D:\Program Files\apache-tomcat-9.0.37\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Program Files\V
isualSVN Server\bin\;C:\ProgramData\chocolatey\bin;D:\Program Files\nodejs\node_global;C:\Program Files\nodejs\;D:\Program Files (x86)\NetSarang\Xshell 7\;E:\hadoop-2.5.2\bin;D:\Program Files\TortoiseSVN\bin;C:
\Program Files\Erlang OTP\bin;H:\Program Files\dev\python\python3.10.4\;H:\Program Files\dev\python\python3.10.4\Scripts;%ANACONDA_HOME%;%ANACONDA_HOME%\Scripts;%ANACONDA_HOME%\Library\bin;%ANACONDA_HOME%\mingw
-w64\bin;D:\Program Files\Git\cmd;D:\Program Files (x86)\NetSarang\Xftp 7\;D:\Program Files\anaconda3;D:\Program Files\anaconda3\Library\mingw-w64\bin;D:\Program Files\anaconda3\Library\usr\bin;D:\Program Files
\anaconda3\Library\bin;D:\Program Files\anaconda3\Scripts;H:\Program Files\dev\python\python3.10.4\Scripts\;H:\Program Files\dev\python\python3.10.4\;D:\Programs Files\Microsoft VS Code\bin;C:\Program Files\Jav
a\jdk1.8.0_261\bin;;.
java.specification.name = Java Platform API Specification
java.class.version = 52.0
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
os.version = 10.0
user.home = C:\Users\xiongpeng
user.timezone = GMT+08:00
java.awt.printerjob = sun.awt.windows.WPrinterJob
file.encoding = UTF-8
java.specification.version = 1.8
user.name = xiongpeng
java.class.path = C:\Program Files\Java\jdk1.8.0_261\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\access-bridge-64.jar;C:\Program Fil
es\Java\jdk1.8.0_261\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\j
fxrt.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\sunec.jar;C:\Program Files\Java\j
dk1.8.0_261\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\e
xt\zipfs.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_261\jre\li
b\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.
8.0_261\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\rt.jar;H:\project\jvmtestdemo\target\classes;D:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\lib\idea_rt.jar
java.vm.specification.version = 1.8
sun.arch.data.model = 64
sun.java.command = com.example.demo.jinfodemo01
java.home = C:\Program Files\Java\jdk1.8.0_261\jre
user.language = zh
java.specification.vendor = Oracle Corporation
awt.toolkit = sun.awt.windows.WToolkit
java.vm.info = mixed mode
java.version = 1.8.0_261
java.ext.dirs = C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
sun.boot.class.path = C:\Program Files\Java\jdk1.8.0_261\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\rt.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\sunrsasign.jar;C:\Program Files\Java\j
dk1.8.0_261\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jfr.jar;C:\Program Files\Java\j
dk1.8.0_261\jre\classes
java.vendor = Oracle Corporation
file.separator = \
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
sun.desktop = windows
sun.cpu.isalist = amd64VM Flags:
Non-default VM flags: -XX:CICompilerCount=4 -XX:InitialHeapSize=668991488 -XX:MaxHeapSize=10697572352 -XX:MaxNewSize=3565682688 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=222822400 -XX:OldSize=446169088 -XX:+UseC
ompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
Command line: -javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\lib\idea_rt.jar=50286:D:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\bin -Dfile.encoding=UTF-8
(2)命令二
jinfo -flags pid
描述:输出全部的虚拟机参数
结果如下:
H:\project\jvmtestdemo>jinfo -flags 14784
Attaching to process ID 14784, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.261-b12
Non-default VM flags: -XX:CICompilerCount=4 -XX:InitialHeapSize=668991488 -XX:MaxHeapSize=10697572352 -XX:MaxNewSize=3565682688 -XX:MinHeapDeltaBytes=524288 -XX:NewSize=222822400 -XX:OldSize=446169088 -XX:+UseC
ompressedClassPointers -XX:+UseCompressedOops -XX:+UseFastUnorderedTimeStamps -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
Command line: -javaagent:D:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\lib\idea_rt.jar=50286:D:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\bin -Dfile.encoding=UTF-8
(3)命令三
jinfo -flag name pid
描述:使用该命令,可以查看指定的 jvm 参数的值
如:查看当前 jvm 进程是否开启打印 GC 日志
H:\project\jvmtestdemo>jinfo -flag PrintGC 14784
-XX:-PrintGC
减号说明该参数没有打开
(4)命令四
jinfo -flag [+|-]name pid
描述:开启或者关闭对应名称的参数
使用 jinfo 可以在不重启虚拟机的情况下,可以动态的修改 jvm 的参数。尤其在线上的环境特别有用。
例如:
jinfo -flag +PrintGC pidjinfo -flag PrintGC pidjinfo -flag +PrintGC pidjinfo -flag PrintGC pid
如下:
(5)命令五
jinfo -flag name=value pid
描述:修改指定参数的值。
和上面的例子相似,但是上面的主要是针对 boolean 值的参数设置的。
如果是设置 value值,则需要使用 name=value 的形式
jinfo -flag HeapDumpPath pid
jinfo -flag HeapDumpPath=d:\dump pid
jinfo -flag HeapDumpPath pid
jinfo -flag HeapDumpPath= pid
jinfo -flag HeapDumpPath pid
如下:
注意:jinfo虽然可以在java程序运行时动态地修改虚拟机参数,但并不是所有的参数都支持动态修改
(6)命令六
jinfo -sysprops pid
描述:输出当前虚拟机进程的全部的系统属性
H:\project\jvmtestdemo>jinfo -sysprops 14784
Attaching to process ID 14784, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.261-b12
java.runtime.name = Java(TM) SE Runtime Environment
java.vm.version = 25.261-b12
sun.boot.library.path = C:\Program Files\Java\jdk1.8.0_261\jre\bin
java.vendor.url = http://java.oracle.com/
java.vm.vendor = Oracle Corporation
path.separator = ;
file.encoding.pkg = sun.io
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
sun.os.patch.level =
sun.java.launcher = SUN_STANDARD
user.script =
user.country = CN
user.dir = H:\project\jvmtestdemo
java.vm.specification.name = Java Virtual Machine Specification
java.runtime.version = 1.8.0_261-b12
java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
os.arch = amd64
java.endorsed.dirs = C:\Program Files\Java\jdk1.8.0_261\jre\lib\endorsed
line.separator =java.io.tmpdir = C:\Users\XIONGP~1\AppData\Local\Temp\
java.vm.specification.vendor = Oracle Corporation
user.variant =
os.name = Windows 10
sun.jnu.encoding = GBK
java.library.path = C:\Program Files\Java\jdk1.8.0_261\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;D:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files (x86)\Common Files\Oracle
\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program
Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;E:\maven\apache-maven-3.6.1\bin;E:\maven\apache-maven-3.6.1\bin;D:\Program Files\apac
he-tomcat-9.0.37\lib;D:\Program Files\apache-tomcat-9.0.37\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;D:\Program Files\V
isualSVN Server\bin\;C:\ProgramData\chocolatey\bin;D:\Program Files\nodejs\node_global;C:\Program Files\nodejs\;D:\Program Files (x86)\NetSarang\Xshell 7\;E:\hadoop-2.5.2\bin;D:\Program Files\TortoiseSVN\bin;C:
\Program Files\Erlang OTP\bin;H:\Program Files\dev\python\python3.10.4\;H:\Program Files\dev\python\python3.10.4\Scripts;%ANACONDA_HOME%;%ANACONDA_HOME%\Scripts;%ANACONDA_HOME%\Library\bin;%ANACONDA_HOME%\mingw
-w64\bin;D:\Program Files\Git\cmd;D:\Program Files (x86)\NetSarang\Xftp 7\;D:\Program Files\anaconda3;D:\Program Files\anaconda3\Library\mingw-w64\bin;D:\Program Files\anaconda3\Library\usr\bin;D:\Program Files
\anaconda3\Library\bin;D:\Program Files\anaconda3\Scripts;H:\Program Files\dev\python\python3.10.4\Scripts\;H:\Program Files\dev\python\python3.10.4\;D:\Programs Files\Microsoft VS Code\bin;C:\Program Files\Jav
a\jdk1.8.0_261\bin;;.
java.specification.name = Java Platform API Specification
java.class.version = 52.0
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
os.version = 10.0
user.home = C:\Users\xiongpeng
user.timezone = GMT+08:00
java.awt.printerjob = sun.awt.windows.WPrinterJob
file.encoding = UTF-8
java.specification.version = 1.8
user.name = xiongpeng
java.class.path = C:\Program Files\Java\jdk1.8.0_261\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\access-bridge-64.jar;C:\Program Fil
es\Java\jdk1.8.0_261\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\j
fxrt.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\sunec.jar;C:\Program Files\Java\j
dk1.8.0_261\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\e
xt\zipfs.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_261\jre\li
b\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.
8.0_261\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\rt.jar;H:\project\jvmtestdemo\target\classes;D:\Program Files\JetBrains\IntelliJ IDEA 2019.3.2\lib\idea_rt.jar
java.vm.specification.version = 1.8
sun.arch.data.model = 64
sun.java.command = com.example.demo.jinfodemo01
java.home = C:\Program Files\Java\jdk1.8.0_261\jre
user.language = zh
java.specification.vendor = Oracle Corporation
awt.toolkit = sun.awt.windows.WToolkit
java.vm.info = mixed mode
java.version = 1.8.0_261
java.ext.dirs = C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
sun.boot.class.path = C:\Program Files\Java\jdk1.8.0_261\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\rt.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\sunrsasign.jar;C:\Program Files\Java\j
dk1.8.0_261\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jfr.jar;C:\Program Files\Java\j
dk1.8.0_261\jre\classes
java.vendor = Oracle Corporation
file.separator = \
java.vendor.url.bug = http://bugreport.sun.com/bugreport/
sun.io.unicode.encoding = UnicodeLittle
sun.cpu.endian = little
sun.desktop = windows
sun.cpu.isalist = amd64