Reading Java system properties from command line

后端 未结 3 2019
执笔经年
执笔经年 2021-01-30 01:05

Is there a better way to print system properties from command line? As we can set the property e.g.

 java  -D=  //set a system property         


        
3条回答
  •  闹比i
    闹比i (楼主)
    2021-01-30 01:39

    You can use the -XshowSettings flag in the Hotspot JVM version 1.7 and up (not supported in 1.6):

    java -XshowSettings:properties -version
    

    OpenJDK has had support for this flag since late 2010.

    Seen in http://marxsoftware.blogspot.de/2016/02/hotspot-jvm-XshowSettings.html

    EDIT 14 Dec 2016

    The Oracle JVM ships with the tool jcmd which allows you to see the flags present in a running JVM. See:

    https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr006.html

    For this use case, you could use:

    jcmd  VM.system_properties
    

    But there are also many other useful commands. For example:

    jcmd  VM.flags
    jcmd  VM.command_line
    jcmd  GC.run 
    

提交回复
热议问题