• Breaking News

    Sunday, 4 October 2015

    How Retrieve All Current Running Process In Java

    In This Tutorial We See How Retrieve All Current Running Processes In Java.

    Below Is Very Simple Approach


     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    package com.kodemaker;
    
    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    
    public class StopExecutionOfProgrammeUsingSleepMethod {
       
      public static void main(String[] args) {
      
       try {
              String currentRunningProcess;
              //get All Running Processes
              Process allRunningProccesses = Runtime.getRuntime().exec("tasklist.exe");
              
              InputStreamReader inputStreamReader = new InputStreamReader(allRunningProccesses.getInputStream());
             
              BufferedReader input =new BufferedReader(inputStreamReader);
              
              //print process one by one
              while ((currentRunningProcess = input.readLine()) != null) {
                  System.out.println(currentRunningProcess); 
              }
              
              input.close();
          } catch (Exception err) {
              err.printStackTrace();
          }
     }
    }
    

    Output Of Above Programme


    Image Name                     PID Session Name        Session#    Mem Usage
    ========================= ======== ================ =========== ============
    System Idle Process              0 Services                   0         24 K
    System                           4 Services                   0      2,308 K
    smss.exe                       356 Services                   0      1,036 K
    csrss.exe                      496 Services                   0      4,140 K
    wininit.exe                    728 Services                   0      3,988 K
    csrss.exe                      760 Console                    1     71,188 K
    winlogon.exe                   808 Console                    1      6,364 K
    services.exe                   864 Services                   0      9,200 K
    lsass.exe                      872 Services                   0     10,388 K
    lsm.exe                        888 Services                   0      3,972 K
    svchost.exe                    984 Services                   0      8,824 K
    svchost.exe                    436 Services                   0     10,756 K
    svchost.exe                    620 Services                   0     18,176 K
    svchost.exe                    660 Services                   0    129,924 K
    svchost.exe                    704 Services                   0     34,136 K
    svchost.exe                   1076 Services                   0     11,664 K
    igfxCUIService.exe            1180 Services                   0      5,408 K
    svchost.exe                   1256 Services                   0     14,336 K
    spoolsv.exe                   1424 Services                   0     10,696 K
    svchost.exe                   1456 Services                   0     13,860 K
    ChgService.exe                1680 Services                   0      3,184 K
    HeciServer.exe                1748 Services                   0      4,760 K
    taskhost.exe                  1808 Console                    1      7,468 K
    LavasoftTcpService.exe        1864 Services                   0     60,068 K
    dwm.exe                       1904 Console                    1     29,820 K
    explorer.exe                  1968 Console                    1     80,820 K
    nis.exe                       1156 Services                   0     11,912 K
    PassThruSvr.exe               2300 Services                   0      3,384 K
    Lavasoft.SearchProtect.Wi     2344 Services                   0     27,820 K
    WebCompanion.exe              2416 Console                    1     60,984 K
    iusb3mon.exe                  2548 Console                    1      4,816 K
    vmware-tray.exe               2588 Console                    1      4,304 K
    CCleaner64.exe                3124 Console                    1        780 K
    nis.exe                       3500 Console                    1     10,164 K
    svchost.exe                   3892 Services                   0      7,416 K
    MonServiceUDisk.exe           3948 Services                   0      3,932 K
    vmware-usbarbitrator64.ex     3988 Services                   0      5,084 K
    vmnat.exe                     4012 Services                   0      4,420 K
    vmnetdhcp.exe                 4060 Services                   0      3,480 K
    vmware-authd.exe              2912 Services                   0     10,108 K
    WmiPrvSE.exe                  3304 Services                   0     15,204 K
    vmware-hostd.exe              4460 Services                   0     35,880 K
    svchost.exe                   4544 Services                   0      7,948 K
    SearchIndexer.exe             4712 Services                   0     23,524 K
    PresentationFontCache.exe     4764 Services                   0     11,824 K
    svchost.exe                   5028 Services                   0      6,240 K
    igfxEM.exe                    4348 Console                    1      8,988 K
    igfxHK.exe                    2480 Console                    1      7,816 K
    igfxTray.exe                  4288 Console                    1      9,708 K
    jhi_service.exe               5324 Services                   0      4,436 K
    LMS.exe                       5896 Services                   0      7,796 K
    AcroRd32.exe                  1284 Console                    1     13,540 K
    AcroRd32.exe                  6036 Console                    1     51,664 K
    audiodg.exe                   5440 Services                   0     16,452 K
    vlc.exe                       1984 Console                    1     40,948 K
    taskmgr.exe                   1068 Console                    1     13,724 K
    mmc.exe                       4176 Console                    1     17,040 K
    WUDFHost.exe                  4636 Services                   0      6,304 K
    chrome.exe                    2288 Console                    1    114,256 K
    chrome.exe                    5744 Console                    1    110,224 K
    chrome.exe                    5688 Console                    1     26,916 K
    chrome.exe                    4300 Console                    1     33,516 K
    chrome.exe                    4884 Console                    1     20,972 K
    chrome.exe                    2072 Console                    1    232,380 K
    chrome.exe                    2684 Console                    1    210,376 K
    chrome.exe                    6920 Console                    1    170,248 K
    chrome.exe                    6584 Console                    1    205,220 K
    eclipse.exe                   4784 Console                    1    571,332 K
    chrome.exe                    9124 Console                    1     29,536 K
    chrome.exe                    7776 Console                    1     47,128 K
    chrome.exe                    6520 Console                    1    188,152 K
    chrome.exe                    9028 Console                    1    159,188 K
    SearchProtocolHost.exe        5016 Services                   0      8,956 K
    SearchFilterHost.exe          2620 Services                   0      6,796 K
    javaw.exe                     7536 Console                    1     17,216 K
    tasklist.exe                  7072 Console                    1      5,456 K
    conhost.exe                   6000 Console                    1      3,388 K
    

    No comments:

    Post a Comment