Reading Java system properties from command line
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 <pid> VM.system_properties
But there are also many other useful commands. For example:
jcmd <pid> VM.flags
jcmd <pid> VM.command_line
jcmd <pid> GC.run
You can use jps a tool that comes with the jdk. It can print out the system properties that were passed to a java process.
For example: On my system eclipse is running and
$ jps -v
outputs
6632 -Dosgi.requiredJavaVersion=1.6 -Xms1024m -Xmx2048m -XX:MaxPermSize=512m
jps
is located in JDK_HOME/bin
EDIT
If you want all the properties use the jinfo tool that is also located in JDK_HOME/bin
. To use it you must know the process id of the java process you want to get information from. E.g.
$ jinfo 6632
This tool also prints out the java.ext.dirs
If you need defaults that your JVM will initially have set unless overridden, use:
java -XshowSettings:properties -version
This is helpful if you don't have a Java application already running, thus no pid to pass to one of the other commands.
If you are seeking the properties of a JVM already running that has properties set via default or set explicitly by command, then use the pid for that JVM found via jps
with the jcmd
or jinfo
commands as listed in answers above.