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 ww. j  av  a  2  s.c om
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.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable