Is there a better way to print system properties from command line? As we can set the property e.g.
java -D<name>=<value> //set a system property
Without writing a class to do that?
If not possible, why is it not possible/feasible/good to do that from the command line ?
Java™ system properties determine the environment in which you run your Java programs. They are similar to system values or environment variables in IBM® i. Starting an instance of a Java virtual machine (JVM) sets the values for the system properties that affect that JVM.
1. How to View Linux System Information. To know only the system name, you can use the uname command without any switch that will print system information or the uname -s command will print the kernel name of your system. To view your network hostname, use the '-n' switch with the uname command as shown.
In Java, you can use System. getProperties() to get all the system properties.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With