I am using intelliJ IDEA.
When I run my programs and close the window, the process still remains. If I run a lot of programs, I need to click disconnect many times.
Is there any way to stop all processes?
Eclipse doesn't have this problem.
I am using intelliJ IDEA.
When I run my programs and close the window, the process still remains. If I run a lot of programs, I need to click disconnect many times.
Is there any way to stop all processes?
Eclipse doesn't have this problem.
IntelliJ 2017.2 now has a "Stop All" button in the "Stop process" menu (the button on the top bar), with the default shortcut ⌘+F2 on Mac OS:
For older versions:
Click the Stop button from the top bar. It will pop open a menu listing all processes. (The stop button at the side of the debug window is per-process, as in your screenshot.)
Hover over the first process, hold Shift, and then click on the last process.
Press Enter.
Screenshot showing the result of steps 1 & 2:
2018.2
on macOS. I have many many bg processes that should die but do not. –
Superheterodyne kill $(ps aux | grep 'java' | awk '{print $2}')
This is a nice little workaround I found on SO a while ago that will kill any process with "java" in the name.
Just copy and paste into the terminal.
kill: kill (some number) failed: no such process
but even when I get that, the processes still stop –
Cimabue kill $(ps aux | grep 'java' | awk '{print $2}')
as an external tool in intellij results in permission errors. –
Sacrificial pkill java
(or pkill '.*java.*'
to match this "contains" behavior). –
Acescent Not exactly perfect, but what you could do is press Ctrl + F2 (shortcut for Stop Process) and hit Enter. It's better than all that mouse clicking and gets you through a list of running processes quite fast.
You can create a script like killJavaProcess
and invoke it in Before launch
section as External tool
For example ~/.bin/killonport
#!/bin/zsh
function help() {
echo "usage: killonport port"
echo "-f don't ask before killing"
echo "-h help"
}
function killListenerOnPort() {
# get script options
zparseopts -E -D h=HELP f=FORCE
[[ -n $HELP ]] &&
help &&
return
local PORT
PORT=$1
[[ -z "$PORT" ]] &&
help &&
return
local LISTEN
# find process listening on port with lsof
LISTEN="$(lsof -nP -iTCP:"$PORT" -sTCP:LISTEN)"
local PROCESS
# remove first line of output lsof
PROCESS="$(echo "$LISTEN" | tail -n +2)"
local HEAD
# get first line of output lsof
HEAD="$(echo "$LISTEN" | head -n 1)"
[[ -z $PROCESS ]] &&
echo "Process not found" &&
return
local COUNT
# assure that found only one process else printing founded processes and exit
COUNT=$(echo "$PROCESS" | wc -l | xargs)
[[ $COUNT -gt 1 ]] &&
printf 'Found more then one process: %s\n%s\n%s\n' "$COUNT" "$HEAD" "$PROCESS" &&
return
# get name and PID
local NAME
NAME=$(echo "$PROCESS" | awk '{print $1}')
local PID
PID=$(echo "$PROCESS" | awk '{print $2}')
# if -f option specified kill silently
[[ -n "$FORCE" ]] &&
kill -9 "$PID" &&
return
# ask confirmation to kill
echo "Kill process '$NAME' with PID '$PID'"
read -qr 'REPL?Continue? (y/n) '
echo
# kill if confirmed
[[ $REPL == 'y' || $REPL == 'Y' ]] &&
kill -9 "$PID"
}
killListenerOnPort "$@"
My environment is Windows, and I am using IntelliJ version 2024.1.2 (Community Edition). IntelliJ often shows that the port is blocked by another application when I restart my Spring Boot application. I resolved this problem by using a shell script to kill the process that occupies the port and adding it to the 'Add Before Launch Task' section of the run configuration.
kill_port_8081.bat:
@echo off
rem Check the port 8081 and kill the process using it
echo Looking for process using port 8081...
for /f "tokens=5" %%a in ('netstat -aon ^| findstr 8081') do (
echo Process found using port 8081: PID %%a
echo Killing process %%a...
taskkill /F /PID %%a
echo Process %%a killed.
)
echo Done.
pause
© 2022 - 2025 — McMap. All rights reserved.