Link to home
Start Free TrialLog in
Avatar of pauloaguia
pauloaguiaFlag for Portugal

asked on

Process List in JAVA

Hi all,

I'm trying to build a JAVA application that, among many other things, fetches a list of the system processes currently executing on the machine and their properties (CPU usage, memory, etc). As it is now I'm parsing the result of a command (like ps on UNIX) to find this information. However this seems to be rather ineficient, especially on *NIX systems that typically have over 100 processes executing at a time.
On Windows I'm using another

I've read somewhere (another forum) that JNI would be the best way to do this task... I think I understood what it was but can someone point me out where to start looking for it?
Or can someone suggest another alternative on how to do this?

I'm fully aware of the fact that whatever the solution, it will be very dependent on the Operating System. My design is prepared to deal with that so it's more of an hassle than a problem.

Any help is much appreciated and the points may be increased to reflect that appreciation.
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> and the points may be increased to reflect that appreciation

500 is the max number of points you can give ;-)
Avatar of durgaprasad_j
durgaprasad_j

hi,
          You can use JNI for this , as the above one pointed.
           In windows, I used JNI and PDH  libraries for this same work. [ you could get many more with PDH].

           In linux, I used JNI and read /proc for getting the processes and cpu usage and everything.
           but, in linux, i dont think you need to use any JNI. You can directly read /proc from java itself.

            In windows , you can use PSAPI also. [I know much about this].

Hope this hleps
DP
Avatar of pauloaguia

ASKER

I had forgotten how fast things work around here ;)

TimYates: That frist link seems promising. I'll have a better look into them later today or maybe tomorrow before accepting any as an answer. I'll be wanting to make up a working example of my own before I can say that either of them is the way to go.

durgaprasad_j: I didn't know what PDH is and I had to take a look around. I don't think that I'll need that, especially since I'd still have to look deeper into it and I'm already charting unknow territory (with JNI). Thanks for the suggestion anyway :)

I'll get back to this later.
As suspected, that first link contained the needed information (still in the process of tweaking it to my needs but I can see I'm on the right track).