首页 / 操作系统 / Linux / 一个启动Java程序的shell脚本
一个启动Java程序的shell脚本,简单处理,未添加pid的处理。附件为一个测试工程,下载地址测试工程的下载地址免费下载地址在 http://linux.linuxidc.com/用户名与密码都是www.linuxidc.com具体下载目录在 /2013年资料/11月/10日/一个启动Java程序的shell脚本下载方法见 http://www.linuxidc.com/Linux/2013-07/87684.htm-------------------------------------分割线-------------------------------------#!/usr/bin/env bash#-----------------------------------------------
#
#
#-----------------------------------------------JVM_OPTIONS="-server -Xms20m -Xmx20m -XX:MaxPermSize=20M
-XX:+HeapDumpOnOutOfMemoryError"#
#帮助信息输出函数
#
usage(){
echo "用法: ./appdemo.sh [options]
其中的选项包括:
--start 启动app
--stop 停止app"
}error_info(){
echo $1
}start(){
JVM_OPTIONS=$JVM_OPTIONS" -Duser.dir=$APPDEMO_HOME"
echo "jvm options:$JVM_OPTIONS"
java $JVM_OPTIONS -jar $APPDEMO_HOME/app-demo.jar start
}stop(){
java -jar $APPDEMO_HOME/app-demo.jar stop
}casage(){
case $1 in
--help)
usage
;;
--start)
start
;;
--stop)
stop
;;
*)
error_info "错误,找不到该选项,请使用--help察看可用选项"
;;
esac
}if [ -z $APPDEMO_HOME ]
then
APPDEMO_BIN=`pwd`
APPDEMO_HOME=$(dirname $APPDEMO_BIN)
fiif [ $# == 0 ] || [ $# -gt 1 ]
then
usage
else
command=$1
casage $command
fi推荐阅读:Java类类型的存储特点 http://www.linuxidc.com/Linux/2013-10/91073.htmJava中两种单例模式小结 http://www.linuxidc.com/Linux/2013-05/84751.htm单例模式(Singleton Pattern) http://www.linuxidc.com/Linux/2012-09/70555.htmJava单例模式实例---读取配置文件 http://www.linuxidc.com/Linux/2012-01/51149.htmJava单例模式(Singleton) http://www.linuxidc.com/Linux/2012-01/51148.htm