how to list currently running jar files in windows using java?
<p>Im developing a simple console application using java. I want to display currently running jar files in my system. The following code is displaying all running process window. </p>

<pre><code>try {


        String cmds[] = { "cmd", "/c", "tasklist" };
        Process myProcess = Runtime.getRuntime().exec(cmds);
        BufferedReader stdout = new BufferedReader(new InputStreamReader(
                myProcess.getInputStream()));
        String line = stdout.readLine();
        File file = new File("writer.txt");
        writer = new BufferedWriter(new FileWriter(file));
        while (line != null) {
            writer.write(line);
            writer.write("\n");
            System.out.println(line);
            line = stdout.readLine();
        }
        writer.close();


    } catch (Exception e) {// Catch exception if any
        System.err.println("Error: " + e.getMessage());
    }  
</code></pre>

<p>Im used </p>

<pre><code>`String cmds[] = { "cmd", "/c", "jps" };`  
</code></pre>

<p>But its not displayed the process. Please anyone give the suggestions. Thanks n advance.</p>
