Question: What system properties are set by OpenJDK's vm so that I can identify that I am running under OpenJDK and not under Sun/Oracle's vm?
As shown here: https://gist.github.com/sinewalker/3890869, the following system properties are NOT sufficient for differentiating between OpenJDK's VM and Sun/Oracle's VM:
System properties:
System.out.println(System.getProperty("java.vendor"));
System.out.println(System.getProperty("java.vendor.url"));
System.out.println(System.getProperty("java.version"));
Outputs the following using OpenJDK's vm (these are the same values you would see on Sun's VM):
Sun Microsystems Inc.
http://java.sun.com/
1.6.0_24
I was expecting the property values to reflect what is output by the java command:
$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.4) (6b24-1.11.4-1ubuntu0.12.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
The biggest difference between OpenJDK and Oracle JDK is licensing. OpenJDK is completely open source Java with a GNU General Public License. Oracle JDK requires a commercial license under Oracle Binary Code License Agreement. But there are many other differences within support and cost, too.
To get a specific system property you can use System. getProperty(String key) or System. getProperty(String key, String def) . Environment variables are set in the OS, e.g. in Linux export HOME=/Users/myusername or on Windows SET WINDIR=C:\Windows etc, and, unlike properties, may not be set at runtime.
System Properties is a section of Microsoft Windows for editing operating system settings, including hardware settings, connectivity, user profiles, security settings, and the computer name.
Try using these:
System.out.println(System.getProperty("java.vm.version"));
System.out.println(System.getProperty("java.runtime.name"));
System.out.println(System.getProperty("java.vm.name"));
You might also like System#getProperties()
:
System.getProperties().list(System.out);
which will list all the current System properties, to System.out
.
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