How to get opened applications list in windows(taskmanager ->application) using java code?

后端 未结 4 2118
执笔经年
执笔经年 2020-12-19 17:14

Here is the snapshot what I want exately!

\"Windows

I am trying to develop a pr

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-19 17:28

    The process list from the command "ps -e":

    try {
          String line;
          Process p = Runtime.getRuntime().exec("ps -e");
          BufferedReader input =
          new BufferedReader(new InputStreamReader(p.getInputStream()));
          while ((line = input.readLine()) != null) {
                 System.out.println(line); //<-- Parse data here.
           }
          input.close();
        } catch (Exception err) {
                err.printStackTrace();
        }
    

    In windows see following used following code

    Process p = Runtime.getRuntime().exec
    (System.getenv("windir") +"\\system32\\"+"tasklist.exe");
    

    Hope the info help!

提交回复
热议问题