How to determine if the -server option is installed on your JVM instance

I am trying to determine if the JVM option (using jdk 1.7u3) server is enabled by default in my JVM instances. Based on my environment (Windows 2008 Server R2) and information about detecting a server machine Server , I expected it to be configured, although I would like to know explicitly. Of course, I could explicitly launch the JVM with the option, and I most likely will, although there is an easy way to define it.

I have already tried the following approaches, although none of them explicitly indicate what I'm looking for. Perhaps it is encoded in some other details.

  • View JVM through jVisualVM and view JVM arguments not explicitly specified
  • Programmatically tried to view JVM arguments matching observables via jVisualVM

    RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean(); List<String> arguments = RuntimemxBean.getInputArguments(); 
  • Use the JVM option -XX: + PrintCommandLineFlags, this provided detailed information, although it has still not been established that the -server option has been set.

+6
source share
3 answers

You can find this by running the java -version command:

below is an example of using the JVM with the -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 the case of -client, a 64-bit client VM will be displayed

In most cases, this depends on the amount of CPU and physical memory. More @ http://docs.oracle.com/javase/7/docs/technotes/guides/vm/server-class.html

+4
source

You can use System.getProperty("java.vm.name") and System.getProperty("java.vm.name") 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 use -server:

 OpenJDK Server VM 
+3
source

Open JConsole → Check java.lang.Runtime attribute → VmName. It displays the Java HotSpot (TM) virtual machine for me. If you use server mode, check the value that it displays for you.

If you need to verify this using a program, you need to request factory control for the above attribute.

+2
source

Source: https://habr.com/ru/post/920676/


All Articles