PlatformManagedObject
public interface RuntimeMXBean extends PlatformManagedObject
A Java virtual machine has a single instance of the implementation class of this interface. This instance implementing this interface is an MXBean that can be obtained by calling the ManagementFactory.getRuntimeMXBean()
method or from the platform MBeanServer
method.
The ObjectName
for uniquely identifying the MXBean for the runtime system within an MBeanServer is:
java.lang:type=Runtime
It can be obtained by calling the PlatformManagedObject.getObjectName()
method. This interface defines several convenient methods for accessing system properties about the Java virtual machine.
Modifier and Type | Method | Description |
---|---|---|
String |
getBootClassPath() |
Returns the boot class path that is used by the bootstrap class loader to search for class files. |
String |
getClassPath() |
Returns the Java class path that is used by the system class loader to search for class files. |
List |
getInputArguments() |
Returns the input arguments passed to the Java virtual machine which does not include the arguments to the main method. |
String |
getLibraryPath() |
Returns the Java library path. |
String |
getManagementSpecVersion() |
Returns the version of the specification for the management interface implemented by the running Java virtual machine. |
String |
getName() |
Returns the name representing the running Java virtual machine. |
default long |
getPid() |
Returns the process ID representing the running Java virtual machine. |
String |
getSpecName() |
Returns the Java virtual machine specification name. |
String |
getSpecVendor() |
Returns the Java virtual machine specification vendor. |
String |
getSpecVersion() |
Returns the Java virtual machine specification version. |
long |
getStartTime() |
Returns the start time of the Java virtual machine in milliseconds. |
Map |
getSystemProperties() |
Returns a map of names and values of all system properties. |
long |
getUptime() |
Returns the uptime of the Java virtual machine in milliseconds. |
String |
getVmName() |
Returns the Java virtual machine implementation name. |
String |
getVmVendor() |
Returns the Java virtual machine implementation vendor. |
String |
getVmVersion() |
Returns the Java virtual machine implementation version. |
boolean |
isBootClassPathSupported() |
Tests if the Java virtual machine supports the boot class path mechanism used by the bootstrap class loader to search for class files. |
getObjectName
default long getPid()
process ID
of the current process.String getName()
String getVmName()
System.getProperty("java.vm.name")
.SecurityException
- if a security manager exists and its checkPropertiesAccess
method doesn't allow access to this system property.String getVmVendor()
System.getProperty("java.vm.vendor")
.SecurityException
- if a security manager exists and its checkPropertiesAccess
method doesn't allow access to this system property.String getVmVersion()
System.getProperty("java.vm.version")
.SecurityException
- if a security manager exists and its checkPropertiesAccess
method doesn't allow access to this system property.String getSpecName()
System.getProperty("java.vm.specification.name")
.SecurityException
- if a security manager exists and its checkPropertiesAccess
method doesn't allow access to this system property.String getSpecVendor()
System.getProperty("java.vm.specification.vendor")
.SecurityException
- if a security manager exists and its checkPropertiesAccess
method doesn't allow access to this system property.String getSpecVersion()
System.getProperty("java.vm.specification.version")
.SecurityException
- if a security manager exists and its checkPropertiesAccess
method doesn't allow access to this system property.String getManagementSpecVersion()
String getClassPath()
System.getProperty("java.class.path")
. Multiple paths in the Java class path are separated by the path separator character of the platform of the Java virtual machine being monitored.
SecurityException
- if a security manager exists and its checkPropertiesAccess
method doesn't allow access to this system property.String getLibraryPath()
System.getProperty("java.library.path")
. Multiple paths in the Java library path are separated by the path separator character of the platform of the Java virtual machine being monitored.
SecurityException
- if a security manager exists and its checkPropertiesAccess
method doesn't allow access to this system property.boolean isBootClassPathSupported()
true
if the Java virtual machine supports the class path mechanism; false
otherwise.String getBootClassPath()
Multiple paths in the boot class path are separated by the path separator character of the platform on which the Java virtual machine is running.
A Java virtual machine implementation may not support the boot class path mechanism for the bootstrap class loader to search for class files. The isBootClassPathSupported()
method can be used to determine if the Java virtual machine supports this method.
UnsupportedOperationException
- if the Java virtual machine does not support this operation.SecurityException
- if a security manager exists and the caller does not have ManagementPermission("monitor").List<String> getInputArguments()
main
method. This method returns an empty list if there is no input argument to the Java virtual machine. Some Java virtual machine implementations may take input arguments from multiple different sources: for examples, arguments passed from the application that launches the Java virtual machine such as the 'java' command, environment variables, configuration files, etc.
Typically, not all command-line options to the 'java' command are passed to the Java virtual machine. Thus, the returned input arguments may not include all command-line options.
MBeanServer access:
The mapped type of List<String>
is String[]
.
String
objects; each element is an argument passed to the Java virtual machine.SecurityException
- if a security manager exists and the caller does not have ManagementPermission("monitor").long getUptime()
long getStartTime()
Map<String,String> getSystemProperties()
System.getProperties()
to get all system properties. Properties whose name or value is not a String
are omitted. MBeanServer access:
The mapped type of Map<String,String>
is TabularData
with two items in each row as follows:
Item Name | Item Type |
---|---|
key | String |
value | String |
SecurityException
- if a security manager exists and its checkPropertiesAccess
method doesn't allow access to the system properties.
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.management/java/lang/management/RuntimeMXBean.html