• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to target the processes that run on my system/pc  RSS feed

 
Roldan Baldo
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to view all the running processes that run on my computer using java
it is ok that you can show me how to view a single process i will try to expand what you post.. thanks
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a question for us beginners. Moving.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bad news - there is no platform dependent way.

In Windows, you can do this in two ways: with JNI and native code, or by running the "tasklist.exe" executable. Try "tasklist /?" for some info.

In Linux, you can use two or three ways. I think JNI is again an option (I haven't found the native calls yet...). The other is the "ps" executable. Try "ps --help" or "man ps" for some info.
Another way I found out that works on at least some systems (RedHat and Ubuntu have been tested) is using procfs. With "new File("/proc").listFiles()" you can get all current processes. The /proc/xxx/cmdline file contains one line that has the command. The /proc/xxx/status file can be fed to a Properties object; the Name property is quite useful. I've tried two Unix systems (SCO and Solaris), and these have different contents in the files - they're definitely not text based though.


If you decide to run an executable, please read this article first.
 
Roldan Baldo
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks campbell

thanks rob, I closely get what you mean but my mind is mentally block for the codes, i have no idea.

 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roldan Baldo wrote:thanks rob, I closely get what you mean but my mind is mentally block for the codes, i have no idea.


Rob gave you 5 suggestions. It would probably be a good idea to start by narrowing it down. Or at the very least, know which operating system you are targeting for.

Once you get it down to one or two options, then you can start researching it. We can help you further if you run into issues during your research.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!