Reading open processes/App list in Java?
I was wondering is there any java system class or something that can read open running processes or least say the running applications on the OS.
Like in a windows platform, we have CTRL+Alt+DEL to view the list. Can we have this inf开发者_开发问答o acquired in a java program?
No.
Since Java is OS agnostic, and not every OS does process listing the same way, you must execute a command line program like ps
for *nix or tasklist
for Windows (after you've determined what OS you're running on, of course) that will list you all processes and then parse them.
As darioo states, this cannot be done in Java alone, but it certainly can be done by melding Java with other languages such as C in one of many ways including using JNI, JNA, or even via reading one program's output stream into Java via a socket.
精彩评论