Java – How do I get a list of all running processes on Linux and Solaris using Java?

How do I get a list of all running processes on Linux and Solaris using Java?… here is a solution to the problem.

How do I get a list of all running processes on Linux and Solaris using Java?

Does anyone know how to get a list of all running processes on Linux and Solaris using Java? I don’t want to use an external program like ps, nor do I want to use proc. I want to do it with a local phone. I found a Windows method that uses JNA. But this doesn’t work for Linux and Solaris.

Solution

Java does not provide an API for this.

What you can do is parse Process p = Runtime.getRuntime().exec("ps");

The result

Related Problems and Solutions