#!/usr/bin/env python
# vim: ts=2:sw=2:ft=python

import subprocess
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("process",
    help="name of Java process")
args = parser.parse_args()

java_processes = subprocess.check_output(["jps"])
lines = [line for line in java_processes.split("\n")]
for line in lines:
  pid_name = line.split(" ", 1)
  if len(pid_name) <= 1:
    continue
  pid, name = pid_name
  if name == args.process:
    subprocess.call(["kill", pid])
