org.optimizationservices.oscommon.util
Class ProcessUtil

java.lang.Object
  extended by org.optimizationservices.oscommon.util.ProcessUtil

public class ProcessUtil
extends java.lang.Object

The ProcessUtil is a process and runtime (or terminal environment) related utility class. For example it provides methods to run commands (e.g. DOS or UNIX commands from within the programming codes.

Since:
OS 1.0
Version:
1.0, 03/14/2004
Author:
Robert Fourer, Jun Ma, Kipp Martin

Constructor Summary
ProcessUtil()
          constructor
 
Method Summary
static double getFreeMemory()
          get free physical memory on the system.
static boolean killProcessByID(java.lang.String processID)
          kill a process by the process id.
static boolean killProcessByName(java.lang.String processName)
          kill a process by the process name.
static boolean launch(java.lang.String command)
          Launch a process specified by a command string.
static boolean launchAndWaitForFinish(java.lang.String command)
          Launch a command specified by a command string and wait for the process to finish before proceeding to the next line.
static boolean launchAndWaitForFinish(java.lang.String command, java.lang.String[] envp, java.io.File dir)
          Launch a command specified by a command string along with some environment parameters and wait for the process to finish before proceeding to the next line.
static void main(java.lang.String[] argv)
          main for test purposes.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessUtil

public ProcessUtil()
constructor

Method Detail

launch

public static boolean launch(java.lang.String command)
Launch a process specified by a command string.

Parameters:
command - holds the command that is usually typed in a terminal.
Returns:
true if the process is launched successfully.

launchAndWaitForFinish

public static boolean launchAndWaitForFinish(java.lang.String command)
Launch a command specified by a command string and wait for the process to finish before proceeding to the next line.

Parameters:
command - holds the command that is usually typed in a terminal.
Returns:
true if the process is launched successfully.

launchAndWaitForFinish

public static boolean launchAndWaitForFinish(java.lang.String command,
                                             java.lang.String[] envp,
                                             java.io.File dir)
Launch a command specified by a command string along with some environment parameters and wait for the process to finish before proceeding to the next line.

Parameters:
command - holds the command that is usually typed in a terminal.
envp - holds array of strings, each element of which has environment variable settings in format name=value.
dir - holds the working directory of the subprocess, or null if the subprocess should inherit the working directory of the current process.
Returns:
true if the process is launched successfully.

killProcessByName

public static boolean killProcessByName(java.lang.String processName)
kill a process by the process name.

Parameters:
processName - holds the process name.
Returns:
whether the process is killed or not; it will return true if there was no such processName.

killProcessByID

public static boolean killProcessByID(java.lang.String processID)
kill a process by the process id.

Parameters:
processID - holds the process id.
Returns:
whether the process is killed or not; it will return true if there was no such processID.

getFreeMemory

public static double getFreeMemory()
get free physical memory on the system.

Returns:
the free physical memory in bytes.

main

public static void main(java.lang.String[] argv)
main for test purposes.

Parameters:
argv - command line arguments.