I'm trying to determine if the JVM (using jdk 1.7u3) -server option is enabled by default on my JVM instances. Based on my environment (Windows 2008 Server R2) and the Server-Class Machine detection information I'd expected it to be set though I'd like to know explicitly. Of course I could explicitly launch the JVM with the option, and I most probably will though is there a simply way to determine same.
I have already tried the following approaches, though neither seems to explicitly state what I'm looking for. Perhaps its encoded in some other details.
Programatically attempted to view the JVM arguments, matches those observed via jVisualVM
RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
List<String> arguments = RuntimemxBean.getInputArguments();
Use JVM option -XX:+PrintCommandLineFlags, this provided verbose details though still no evidence that the -server option was set.
You can find that by running java -version command:
below is example for JVM running with -server flag
java version "1.7.0_17"
Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
In case of -client, it would show 64-Bit Client VM
Most of the cases it depends on number of CPU's and physical memory. More @ http://docs.oracle.com/javase/7/docs/technotes/guides/vm/server-class.html
You can use System.getProperty("java.vm.name")
and parse the string.
Example:
public class Test {
public static void main(String{[] args) {
System.out.println(System.getProperty("java.vm.name"));
}
}
This example will result in:
OpenJDK Client VM
or if you are using -server:
OpenJDK Server VM
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