org.jppf.utils
Class SystemUtils

java.lang.Object
  extended by org.jppf.utils.SystemUtils

public final class SystemUtils
extends Object

Collection of utility methods used as a convenience for retrieving JVM-level or System-level information.

Author:
Laurent Cohen

Method Summary
static TypedProperties getEnvironment()
          Get a map of the environment variables.
static TypedProperties getNetwork()
          Get a map of the environment variables.
static int getPID()
          Return the current process ID.
static TypedProperties getRuntimeInformation()
          Get information about the number of processors available to the JVM and the JVM memory usage.
static TypedProperties getStorageInformation()
          Get storage information about each file system root available on the current host.
static TypedProperties getSystemProperties()
          Return a set of properties guaranteed to always be part of those returned by System.getProperties().
static boolean isMac()
          Determine whether the current OS is Mac-based.
static boolean isWindows()
          Determine whether the current OS is Windows.
static boolean isX11()
          Determine whether the current OS is X11-based.
static long maxFreeHeap()
          Compute the maximum memory currently available for the Java heap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSystemProperties

public static TypedProperties getSystemProperties()
Return a set of properties guaranteed to always be part of those returned by System.getProperties().

Returns:
the properties as a TypedProperties instance.

getRuntimeInformation

public static TypedProperties getRuntimeInformation()
Get information about the number of processors available to the JVM and the JVM memory usage.

Returns:
a TypedProperties instance holding the requested information.

getStorageInformation

public static TypedProperties getStorageInformation()
Get storage information about each file system root available on the current host. This method first checks that the Java version is 1.6 or later, then populates a TypedProperties object with root name, free space, total space and usable space information for each root.

If the Java version is before 1.6, only the root name is retrieved. An example root name would be "C:\" for a Windows system and "/" for a Unix system.

Returns:
TypedProperties object with storage information.

getEnvironment

public static TypedProperties getEnvironment()
Get a map of the environment variables.

Returns:
a mapping of environment variables to their value.

getNetwork

public static TypedProperties getNetwork()
Get a map of the environment variables.

Returns:
a mapping of environment variables to their value.

maxFreeHeap

public static long maxFreeHeap()
Compute the maximum memory currently available for the Java heap.

Returns:
the maximum number of free bytes in the heap.

isWindows

public static boolean isWindows()
Determine whether the current OS is Windows.

Returns:
true if the system is Windows, false otherwise.

isX11

public static boolean isX11()
Determine whether the current OS is X11-based.

Returns:
true if the system is X11, false otherwise.

isMac

public static boolean isMac()
Determine whether the current OS is Mac-based.

Returns:
true if the system is Mac-based, false otherwise.

getPID

public static int getPID()
Return the current process ID.

Returns:
the pid as an int, or -1 if the pid could not be obtained.


Copyright © 2005-2010 JPPF Team.