You can use the ps command to see what is running. To check for Java apps, use:
ps -ef | grep java
Alternately, you could use the jps app that comes with the JDK - it lists the Java processes running and gives the main class name.
AS far as a full script goes, you are on your own,:
NotACodeMill