Search code examples
javawindowspid

Java, Checking if any process ID is currently running on Windows


Is it possible to check the existence of process from Java in Windows.

I have its possible PID, I want to know if it is still running or not.


Solution

  • See if this can help:

    http://blogs.oracle.com/vaibhav/entry/listing_java_process_from_java

    That post explains how to get all PIDs running on a Windows machine: you'd have to compare the output of the cmd call with your PID, instead of printing it.

    If you're on Unix-like systems you'd have to use with ps instead of cmd

    Calling system commands from your java code is not a very portable solution; then again, the implementation of processes varies among operating systems.