0

I'm learning some JVM tools like jstat, jmap, jtack, etc. When I type jstat in the commandline, it responds with the following messages:

Usage:
    jmap [option] <pid>
        (to connect to running process)
    jmap [option] <executable <core>
        (to connect to a core file)
    jmap [option] [server_id@]<remote server IP or hostname>
        (to connect to remote debug server)

where <option> is one of:
    <none>               to print same info as Solaris pmap
    -heap                to print java heap summary
    -histo[:live]        to print histogram of java object heap; if the "live"
                         suboption is specified, only count live objects
    -permstat            to print permanent generation statistics
    -finalizerinfo       to print information on objects awaiting finalization
    -dump:<dump-options> to dump java heap in hprof binary format
                         dump-options:
                           live         dump only live objects; if not specified,
                                        all objects in the heap are dumped.
                           format=b     binary format
                           file=<file>  dump heap to <file>
                         Example: jmap -dump:live,format=b,file=heap.bin <pid>
    -F                   force. Use with -dump:<dump-options> <pid> or -histo
                         to force a heap dump or histogram when <pid> does not
                         respond. The "live" suboption is not supported
                         in this mode.
    -h | -help           to print this help message
    -J<flag>             to pass <flag> directly to the runtime system

The question is that I'm confused with the option -J.

-J<flag>             to pass <flag> directly to the runtime system

When I type jstat -J-version, it says

java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

What does this option used for and what does "flag" mean exactly?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Eric Fan
  • 43
  • 8
  • Have you considered consulting the [documentation](http://docs.oracle.com/javase/7/docs/technotes/tools/share/jstat.html)? – user207421 Sep 11 '15 at 08:11
  • 3
    @EJP I think it's pretty obvious he did read the documentation as it is well documented in his question. – Craig Sep 11 '15 at 08:28
  • @EJP I thought the help message 'to pass directly to the runtime system' is the official explaination to this option,but I don't understand this.So I searched the google with keyword 'pass directly to the runtime system' rather than 'jstat', as a result I gotta nothing valuable.It's pretty clear after reading the documentation referred by EJP,-J just means javaOption.Much Thanks. – Eric Fan Sep 11 '15 at 10:21

2 Answers2

4

Oracle online documentation about jstat is more clear:

-JjavaOption

Passes javaOption to the Java application launcher. For example, -J-Xms48m sets the startup memory to 48 MB. For a complete list of options, see java(1).

This option is used to pass Java option to the runtime JRE, like setting memory sizes. The list of possible options can be viewed here.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • Thanks.It's very clear after I read the Oracle Docs.I searched the google with keyword 'pass directly to the runtime system' rather than 'jstat', as a result I gotta nothing valuable. – Eric Fan Sep 11 '15 at 10:13
2

It means that it passes that flag through to the child JVM process that jstat invokes.

For example, jstat -J-version effectively invokes:

java -version

which has the effect of printing out the JVM version.

Andy Turner
  • 137,514
  • 11
  • 162
  • 243