Java get list of local operating system processes

Source: Internet
Author: User

Package Com.wa.xwolf.sblog.util;import Java.io.bufferedinputstream;import Java.io.bufferedreader;import Java.io.inputstreamreader;import Java.nio.charset.charset;public class Processutil {public static void main (St        Ring[] args) throws Exception {//Create system process Processbuilder PB = new Processbuilder ("tasklist");        Process p = Pb.start (); BufferedReader out = new BufferedReader (New InputStreamReader new Bufferedinputstream (P.getinputstream ()),        Charset.forname ("GB2312"));        BufferedReader err = new BufferedReader (new InputStreamReader (New Bufferedinputstream (P.geterrorstream ()));        SYSTEM.OUT.PRINTLN ("Window System process list");                String Ostr;        while ((Ostr = Out.readline ()) = null) System.out.println (OSTR);        String estr = Err.readline ();        if (estr! = null) {System.out.println ("\nerror Info");        System.out.println (ESTR); }    }}

Console output:

Window system Process list image name PID session name Session # Memory use ========================= ======== ===========                           ===== =========== ============system Idle Process 0 Services 0 Ksystem                   4 Services 0 4,600 Ksmss.exe 372 services 0 176 Kcsrss.exe 548 Services 0 1,680 Kwininit.exe 6 Services 0 Kcsrss.exe 632 Console 1 52,584 Kwi                   Nlogon.exe 680 Console 1 2,024 Kservices.exe 724 Services                        0 4,804 Klsass.exe 740 Services 0 5,632 Klsm.exe      748 Services 0 1,564 Ksvchost.exe 844 Services 0 3,408 Ksvchost.exe                   952 Services 0 4,200 Ksvchost.exe 1068 Services                   0 10,508 Ksvchost.exe 1100 Services 0 41,200 Ksvchost.exe  1128 Services 0 18,856 Ksvchost.exe 1252 Services 0 6,656 K Copy Code


Java get list of local operating system processes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.