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.
. . .

Loading properties from an XML file in JDK 1.5

ReadProps.java:

import java.util.*;
import java.io.*;

public class ReadProps
{
   public static void main(String []args) {
      Properties props = new Properties();
       
      try {
         props.loadFromXML(new FileInputStream(new File("config.xml")));
      }
      catch(IOException e) { 
         e.printStackTrace();
      }
       
      System.out.println(props);
   }
}