How long has the VM been running

In JDK 1.5, use the RuntimeMBean management class in the java.lang.management package.

Main.java:

import java.lang.management.*;
import java.util.*;
 
public class Main
{
   public static void main(String []args) {
      RuntimeMBean mbean = ManagementFactory.getRuntimeMBean();
      while (true) {
         long uptime = mbean.getUptime();
          
         System.out.println("VM has been running for " + uptime + " ms.");
         try { Thread.sleep(1500); } catch(Exception e) { }
      }
   }
}

outputs:

VM has been running for 50 ms.
VM has been running for 1552 ms.
VM has been running for 3054 ms.
VM has been running for 4557 ms.
VM has been running for 6059 ms.
. . .