This is what I have used in the past. It was used in some WebSphere development when the only way to shutdown WebSphere if you weren't on the WebSphere console was to kill all the java processes.
Syntax for executing the script is:
myscript.sh <process>
# This line gets the process number for the value passed in the
# command (java, for WebSphere) and writes the PID only to
# a text file.
PID=`ps -e | grep $1 | awk '{ print $1 }' > /home/utility/bin/pid.txt`
# This line cats the file created in the line above and says while
# catting the file, read each line.
cat /home/utility/bin/pid.txt | while read LINE
# This line tells the system to do a kill -9 on each PID that is
# listed in the pid.txt file. There may be an error message
# because the grep for the process is also listed but by the time
# the kill command is executed, the grep has already died.
do kill -9 $LINE
# This line closes up the do line.
done