Class ProcessUtils

java.lang.Object
com.sun.enterprise.universal.process.ProcessUtils

public final class ProcessUtils extends Object
Includes a somewhat kludgy way to get the pid for "me". Another casualty of the JDK catering to the LEAST common denominator. Some obscure OS might not have a pid! The name returned from the JMX method is like so: 12345
Author:
bnevins
  • Method Details

    • main

      public static void main(String[] args)
    • getExe

      public static File getExe(String name)
      Look for name in the Path. If it is found and if it is executable then return a File object pointing to it. Otherwise return nu
      Parameters:
      name - the name of the file with no path
      Returns:
      the File object or null
    • getPid

      public static int getPid()
      Try and find the Process ID of "our" process.
      Returns:
      the process id or -1 if not known
    • kill

      public static String kill(int pid)
      Kill the process with the given Process ID.
      Parameters:
      pid -
      Returns:
      a String if the process was not killed for any reason including if it does not exist. Return null if it was killed.
    • killJvm

      public static String killJvm(String classname)
      Kill the JVM with the given main classname. The classname can be fully-qualified or just the classname (i.e. without the package name prepended).
      Parameters:
      pid -
      Returns:
      a String if the process was not killed for any reason including if it does not exist. Return null if it was killed.
    • isProcessRunning

      public static Boolean isProcessRunning(int aPid)
      If we can determine it -- find out if the process that owns the given process id is running.
      Parameters:
      aPid -
      Returns:
      true if it's running, false if not and null if we don't know. I.e the return value is a true tri-state Boolean.