How to kill a specific java process by application name
Solution 1
Using taskkill, you can kill a process based on window title using a filter.
taskkill /F /FI "WindowTitle eq Spotify" /T
/F
- force task kill/T
- Kill child process/FI
- Filter the tasks
If the window title has quotes in it, you can escape the nested quotes with a backslash (\
).
You can use tasklist in a similar manner to search for a task based on its window title.
tasklist /V /FI "WindowTitle eq Spotify"
You can use the *
as a wildcard to match a pattern
tasklist /V /FI "WindowTitle eq S*"
Solution 2
For all java.exe processes there is a "Commandline" attribute associated with it which you can get using :
wmic PROCESS where "name like '%java%'" get Commandline
generally you will find Jar file ( specific to java process) as part of the command line
you can use that name of jar file or any part of command line to filer out the java processes and get the desired process id using
wmic PROCESS where "name like '%java.exe%' AND CommandLine like '%<part of commnad line argument>%'"get Processid
instead of using get Processid in above command , you can use call Terminate to directly kill the process.
wmic PROCESS Where "name Like '%java.exe%' AND CommandLine like '%<part of commnad line argument>%'" Call Terminate
Related videos on Youtube
Eugene S
Professional Software Testing Engineer specializing in automation with Open Source tools. Interested in: Test automation: Selenium, BDD, Cucumber Programming: Java, Python, Spring Data scraping Audio: recording/mixing
Updated on September 18, 2022Comments
-
Eugene S over 1 year
Usual
taskkill /im "java.exe"
will kill all java processes in the list. I however, want to kill a specific one. The problem is to identify the right process as there are multiplejava.exe
processes that run simultaneously and not related to each other.Is there any way to kill a process by application name rather than by process name? I have the application name showing in the Applications tab in Task Manager and manually I can right click on that application and choose "Go To Process". It will highlight the relevant java process. Is there anyway to do it from command line?
-
Eugene S almost 5 yearsThanks I will keep that in mind