kill $(ps aux | grep "java" | grep -v 'grep' | awk '{print $2}')
kills all java processes. grep -v ‘grep’ ignores the current grep command
If you need to give them a chance to gracefully shut down first then do this
pids="$(ps -C "java" -o pid,bsdstart | fgrep -v ":" | awk '{print $1}')"
for signal in 15 1 9
do
kill -$signal $pids 2>/dev/null
sleep 5
done