- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get the JVM uptime from RuntimeMXBean in Java
RuntimeMXBean in the management interface for the runtime system of the Java virtual machine −
RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean();
Let us get the JVM uptime using the getUptime() method −
runtimeMX.getUptime()
The following is an example −
Example
import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.util.Date; public class Demo { public static void main(String args[]) throws Exception { RuntimeMXBean runtimeMX = ManagementFactory.getRuntimeMXBean(); System.out.println("JVM Uptime = "+runtimeMX.getUptime() + " ms"); } }
Output
JVM Uptime = 81 ms
Let us run the code again, to get the following output −
JVM Uptime = 78 ms
- Related Articles
- Get ClassPath from RuntimeMXBean in Java
- Get the system properties from RuntimeMXBean in Java
- Get Boot path from RuntimeMXBean in Java
- Get system start time from RuntimeMXBean in Java
- How to get the System uptime with PowerShell?
- Verification in Java (JVM)
- JVM shutdown hook in Java
- Java (JVM) memory model
- Java (JVM) Memory Types
- What is JVM, Java virtual machine?
- Explain Java Virtual Machine (JVM) Architecture
- What is Java Virtual Machine (JVM)?
- Java Virtual Machine (JVM) Stack Area
- What is Unified JVM Logging in Java 9?
- Difference between JDK, JRE and JVM in Java

Advertisements