Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get process information using pid with Java?

I have the process id of a process. Can I get other information about process like CPU%, memory, exe name, etc?

I have seen that there is no built-in function to get all this. How to do this with Native?

Please help.

like image 427
Ravi Kumar Gupta Avatar asked Feb 20 '26 07:02

Ravi Kumar Gupta


1 Answers

Java is a platform independent platform. Its specification doesn't define anything about pid. So you cannot find a general/portable way to manipulate pid. Although it is not a good practice, you can make an implemenation for a specific platform.

On windows you can use tasklist to get the full list of PIDs and filter for the one you want.

On Unix/Linux system you can use ps ax | grep to get your information.

like image 89
StarPinkER Avatar answered Feb 23 '26 00:02

StarPinkER