• Post Reply Bookmark Topic Watch Topic
  • New Topic

Get a list of Processes  RSS feed

 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I just wanted to know, is there a way to get a list of processes which are currently running in the Operating System.
Thanks...
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I doubt there is a platform-independent way to do such a thing.
In any case, I'm moving this to the Threads and Synchronization forum, where folks are most likely to have an idea...
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, why would you want to do such a thing?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no Java API for this. You have two choices: a platform-dependent JNI function that uses the native OS's mechanism for getting this list, or using Runtime.exec() to run some platform-dependent program that returns the list as text and then parsing the result.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please give me any idea if I want to do this by Runtime.exec()...
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What operating system are you using?
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Windows 2000 platform. I don't mind doing this machine dependantly as well as using JNI.
Please do help me with this. This is an assignment.
Thanks.........
 
Dmitry Melnik
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might look at this Win32 API fuction:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/perfmon/base/enumprocesses.asp
then, follow the links for code examples, etc. And get more info on process-relevant part of Win32 API here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/process_and_thread_functions.asp
And you need to wrap this stuff in JNI, of course...
 
Dmitry Melnik
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...and using pure Java you can track (to some degree) only the processes which your application have started by callimg Runtime.exec(...) If you need to track other processes, it will not work for you.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Thank you very much for the answers. It really helps...........
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I am facing a problem. The link above which was given to me, provided me a source code written on C or C++. Could you please tell me which software do I have to use to run the program.
Thanks....
 
Dmitry Melnik
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C/C++ development tool like Microsoft Visual Studio (IMHO overkill for your task), or "gcc" http://gcc.gnu.org/
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bloodshed's Dev C++ is pretty easy to use, and it's free.
If you've further questions on C/C++ development, let me suggest that you mosey on over to Gregg's forums dedicated to the subject.
 
Ransika deSilva
Ranch Hand
Posts: 524
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for the answers......
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!