Java Data Type Tutorial - Java Runtime.getRuntime()








Syntax

Runtime.getRuntime() has the following syntax.

public static Runtime getRuntime()

Example

In the following code shows how to use Runtime.getRuntime() method.

/*from  w  w w.ja  v a 2s. com*/
public class Main {

   public static void main(String[] args) {

      // get the current runtime assosiated with this process
      Runtime run = Runtime.getRuntime();

      // print the current free memory for this runtime
      System.out.println("" + run.freeMemory());
   }
}

The code above generates the following result.