The Java hotspot vpm can be run with -client or -server argument. If neither is specified then it chooses one according to some rules.
Is it possible to tell whether a running VM is running in client or server mode when the mode is not specified on command line? I need this on a Windows box outside the running process.
I realize this is not a programming question, but I hope it is ok because it is programming related. Thanks in advance.
A JVM server is a runtime environment that can handle many concurrent requests for different Java™ applications in a single JVM.
A Java client is a Java application written to execute in a Java Virtual Machine (JVM) on a client device – typically a desktop, mobile device, or other endpoint.
The Java HotSpot Client Virtual Machine* serves as a replacement for both the "classic" virtual machine and the Just-in-time (JIT) compilers used by previous versions of the Java 2 SDK to offer improved runtime performance for applications and applets.
In Java, you could check this with this code:
String s = System.getProperty("java.vm.name");
// s = Java HotSpot(TM) Server VM
But this will be highly vendor specific.
From the command line, you could use jinfo (used to check a value of a given HotSpot VM option)
C:\>"c:\Program Files\Java\jdk1.6.0_16\bin\jps.exe" -l -m
21812 sun.tools.jps.Jps -l -m
19244 (eclipse)
C:\>"c:\Program Files\Java\jdk1.6.0_16\bin\jinfo.exe" -flag NewRatio 19244
-XX:NewRatio=12
Since:
[x86 -server: 8; x86 -client: 12]
12 means "Client".
Connect to the running Java process with jvisualvm. This will let you see the JVM arguments that have been used.
You can retrieve this information connecting to the MBean server. If you are running a Sun VM, you have an MBean with name "java.lang:type=Runtime" which exposes the attribute "VmName", whose value is the same as system property "java.vm.name". In example, for a server vm the value will be something like "Java HotSpot(TM) Server VM". VM's from other vendors may use a similar mechanism.
You can connect to the MBean server either using the tools included in the JDK, like jconsole or jvisualvm, or by writing your own tool using JMX if you need programmatic access.
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