I need to get process ID of running task. I am not sure why below code is failing. It is going unresponsive everytime i run the code as standalone.
Map<String,String> checkRunningProcess(){
Map<String,String>processPid = new HashMap<String,String>();
try{
String line,processName;
Process p = Runtime.getRuntime().exec("tasklist.exe /fo csv /nh");
BufferedReader input = new BufferedReader (new InputStreamReader(p.getInputStream()));
while((line = input.readLine())!=null){
String all[] = line.split(",");
all[0] = all[0].replace("\"","");
all[1] = all[1].replace("\"", "");
//System.out.println(all[0]+all[1]);
processPid.put(all[0],all[1]);
}
}catch(Exception err){
err.printStackTrace();
}
return processPid;
}