简体   繁体   中英

PID java application and kill

I would like to assign PID to my java application (if it's possible), and kill every other javaw.exe.

Runtime.getRuntime().exec("taskkill /F /IM javaw.exe");

or PID

Runtime.getRuntime().exec("taskkill /F /PID <ID>");

I know this will kill all javaw.exe , but I need my application still up and running.

It should kill specific java application, but they are having random PID's assign. I though the easiest way would be close all java applications running except mine.

I've did it a little bit different. I've used "wmic", to list all the java process and PID at the end. I am taking the the last numbers and killing them.

wmic process where "name like '%javaw%'"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM