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 Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static FilegetExe(String name)Look for name in the Path.static intgetPid()Try and find the Process ID of "our" process.static ProcessStategetProcessRunningState(int aPid)If we can determine it -- find out if the process that owns the given process id is running.static BooleanisProcessRunning(int aPid)Deprecated, for removal: This API element is subject to removal in a future version.static Stringkill(int pid)Kill the process with the given Process ID.static StringkillJvm(String classname)Kill the JVM with the given main classname.static voidmain(String[] args)
-
-
-
Method Detail
-
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
@Deprecated(forRemoval=true, since="6.21.0") public static Boolean isProcessRunning(int aPid)
Deprecated, for removal: This API element is subject to removal in a future version.The deprecated isProcessingRunning method DO NOT USE! Retained for semantic versioning. Replaced bygetProcessRunningState(int).
-
getProcessRunningState
public static ProcessState getProcessRunningState(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.
-
-