你的位置:首页 > 软件开发 > Java > 〖Linux〗将Jar文件打包成Linux可执行文件

〖Linux〗将Jar文件打包成Linux可执行文件

发布时间:2015-04-27 20:00:28
因为不想敲写 java -jar jarfile,而是想直接敲写 ./jarfile 就能够跑起程序 #!/bin/bash - #===================================================================== ...

因为不想敲写 java -jar jarfile,而是想直接敲写  ./jarfile 就能够跑起程序

 

#!/bin/bash - #===============================================================================##     FILE: shell_pack.sh# #     USAGE: ./shell_pack.sh # #  DESCRIPTION: # #    OPTIONS: ---# REQUIREMENTS: ---#     BUGS: ---#     NOTES: ---#    AUTHOR: lwq (28120), scue@vip.qq.com# ORGANIZATION: #    CREATED: 04/22/2015 02:38:01 PM CST#   REVISION: ---#===============================================================================#=== FUNCTION ================================================================#     NAME: usage# DESCRIPTION: Display usage information.#===============================================================================function usage (){    cat <<- EOT Usage : $0 [options] -p package -s script file1 file2 file3 .. Options: -h|help    Display this message -p|package  The output package name -j|jar file  The jar fileEOT}  # ---------- end of function usage ----------#-----------------------------------------------------------------------# Handle command line arguments#-----------------------------------------------------------------------while getopts ":hp:j:" optdo case $opt in  h|help  ) usage; exit 0  ;;  p|package ) package_name=$OPTARG ;;  j|jar   ) jar_file=$OPTARG ;;  \?    ) echo -e "\n Option does not exist : $OPTARG\n"     usage; exit 1  ;; esac  # --- end of case ---doneshift $(($OPTIND-1))if [[ -z $package_name ]]; then  echo "package_name can't not be empty"  usage  exitfiif [[ -z $jar_file ]]; then  echo "jar_file can't not be empty"  usage  exitfigenerate_wrapper_script(){  local wrapper_script=$1  cat <<-'EOT' >$wrapper_script#!/bin/shjava -jar $0 "$@"if [ $? -ne 0 ]; then  echo "run jar file failed."  exit 1fiexit 0#__SCRIPTEND__EOT}wrapfile=wrap_$$.shecho -e "start packing ..\n"generate_wrapper_script $wrapfilecat $wrapfile $jar_file > $package_namechmod +x $package_nameecho -e "\noutput: $package_name\n"rm -f $wrapfile

原标题:〖Linux〗将Jar文件打包成Linux可执行文件

关键词:linux

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录