getUptime
long getUptime()
- Returns the uptime of the Java virtual machine in milliseconds.
-
- Returns:
- uptime of the Java virtual machine in milliseconds.
Example:
package com.crunchify.tutorials; /** * @author Crunchify.com */ import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; public class CrunchifyGetJVMUpTime { public static void main(String[] args) { RuntimeMXBean runtimeBean = ManagementFactory.getRuntimeMXBean(); long upTime = runtimeBean.getUptime(); System.out.printf("Up Time = %d (ms)", upTime); } }
Output:
Up Time = 28 (ms)