Java Programmers sometimes need to understand JVM-related parameters, either out of curiosity or work needs. Some parameters are listed in the Oracle document (Click here). Not all parameters are listed, and some parameters are enabled or disabled by default, in some cases, setting a parameter does not take effect. Sometimes you want JVM to do something, but you don't know which parameter can be used. The following describes some methods to list all parameters, so that you have a clear goal in your research or Google.
If you want to check whether the online running JVM has set those parameters and what takes effect, you may use the following methods:
1. Use the ps command in Linux to find the parameters used to start a Java application.
ps -ef | grep "your java app name"
This command will display all the parameters passed to the Java command when you start the Java application. You can see the JVM parameters in it.
2. Check the startup script or parameter configuration.
You may not be able to find all the places where this JVM parameter is set.
Generally, the above two methods must be familiar with or familiar with JVM, at least specific parameters.
In fact, the JVM has a parameter-XX: + printflagsfinal, which can print almost all JVM-supported parameters and their default values. If you want to check whether your Java application uses those parameters, you just need to add this parameter at startup.
1. view the parameters supported by your JDK.
java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version
2. Print JVM parameters enabled for Java applications
java -XX:+PrintFlagsFinal -classpath=/path/to/your/libs MainClass
3. If your Java application is already running, you cannot use the jinfo tool to check whether a JVM parameter has taken effect.For example, the well-known G1 garbage collector is not started by default in jdk7update3 in both client and server (-server) mode.
Jinfo is released along with JDK. Use JPs to find the Java application PID first. Run jinfo directly to view the instructions.
jinfo -flag UseParallelOldGC 31072
-XX:+UseParallelOldGC
There are still many tools used in JDK. You can try every command in the $ {java_home}/bin directory one by one.