Thursday 16 August 2018

jcmd: VM.command_line: Get the command line used to start this VM instance

jcmd provides ‘VM.command_line’ command to print the command line used to start this VM instance.

For example,

HelloWorld.java
public class HelloWorld {
 public static void main(String args[]) throws Exception {
  Thread t1 = new Thread() {
   public void run() {
    while (true) {
     try {
      Thread.sleep(1000);
     } catch (Exception e) {

     }
    }
   }
  };

  t1.start();
 }
}

Compile HelloWorld.java.

Run HelloWorld application using below command.
java -Xms213m -Xmx1025m -classpath . HelloWorld 1 2 3

Open command prompt and execute jcmd command.
C:\>jcmd
13220
16932 sun.tools.jcmd.JCmd
19924 HelloWorld 1 2 3


As you see the output of jcmd command, HelloWorld application is running with process id 19924.


Execute the command 'jcmd 19924 help', to get list of available commands with the process id 19924.



As you see above image, 'VM.command_line' command is available with process id 19924.


Execute the command 'jcmd 19924 VM.command_line', to print the command line used to start this Vm instance.
C:\>jcmd 19924 VM.command_line
19924:
VM Arguments:
jvm_args: -Xms213m -Xmx1025m
java_command: HelloWorld 1 2 3
java_class_path (initial): .
Launcher Type: SUN_STANDARD




Previous                                                 Next                                                 Home

No comments:

Post a Comment