Im trying to kill a process from my JAVA code:
File file = new File("c://test//test.jar");
String folderToFile = file.getAbsolutePath();
String filePath = folderToFile.substring(0,folderToFile.lastIndexOf(File.separator));
String[] cmd = String.format("cmd /c java -jar %s", file.getName()).split(" ");
Process pSimulator = (new ProcessBuilder(cmd))
.directory(new File(filePath))
.redirectErrorStream(true)
.start();
Thread.sleep(300);
pSimulator.destroy();
I don't know why but the process that i'm trying to kill remains open... the "test.jar" that i'm running here is just a rendom jar that i've picked on the web...
any ideas?