Your Java application is a daemon and you want to stop it more gracefully than "killall java".
The example below is what you need:
#!/bin/sh
#
# init script for a Java application
#
# Check the application status
#
# This function checks if the application is running
check_status() {
# Running ps with some arguments to check if the PID exists
# -C : specifies the command name
# -o : determines how columns must be displayed
# h : hides the data header
s=`ps -C 'java -jar /path/to/application.jar' -o pid h`
# If somethig was returned by the ps command, this function returns the PID
if [ $s ] ; then
return $s
fi
# In any another case, return 0
return 0
}
# Starts the application
start() {