java 打包成服务_maven javaProject打包发布成服务
1 @echo off2
3 rem 修改控制臺(tái)顏色4 color 1d5
6 rem * 使用JavaService將TestTimer安裝為Windows服務(wù)的腳本7 rem *8 rem * JavaService - Windows NT Service Daemon for Java applications9 rem * Copyright (C) 2006 Multiplan Consultants Ltd. LGPL Licensing applies10 rem * Information about the JavaService software is available at the ObjectWeb11 rem * web site. Refer to http://javaservice.objectweb.org for more details.12
13 rem 開始批處理文件中環(huán)境改動(dòng)的本地化操作,在使用endlocal后環(huán)境將恢復(fù)到原先的內(nèi)容14 SETLOCAL15
16 rem 設(shè)置環(huán)境變量,指向當(dāng)前路徑17 SET BASE_PATH=%CD%18 rem 設(shè)置Java path: jre_home19 SET JRE_HOME=C:\Program Files\Java\jre720 rem 判斷JRE_HOME是否正確21 if "%JRE_HOME%" == "" goto no_java22 if not exist "%JRE_HOME%\bin\java.exe" goto no_java23 rem 設(shè)置jvm內(nèi)存分配情況24 set JVM_MEMORY=-Xms256m -Xmx512m25
26 rem 設(shè)置jvmdll使用哪一種模式27 SET jvmdll=%JRE_HOME%\bin\client\jvm.dll28 if not exist "%jvmdll%" SET jvmdll=%JRE_HOME%\bin\server\jvm.dll29 if not exist "%jvmdll%" goto no_java30
31 rem 設(shè)置JavaService路徑32 set JSBINDIR=E:\project33 set JSEXE=%JSBINDIR%\JavaService.exe34
35 rem 判斷jar是否正確36 SET acctjar=%BASE_PATH%\UDPServer-0.0.1-SNAPSHOT.jar37 if not exist "%acctjar%" goto no_peer38
39 @echo . Using following version of JavaService executable:40 @echo .41 "%JSEXE%" -version42 @echo .43
44 rem parameters and files seem ok, go ahead with the service installation45 @echo . %BASE_PATH% +++++++++++++++++++46
47 rem 處理該批處理的輸入?yún)?shù),后臺(tái)服務(wù)啟動(dòng)模式:自動(dòng)48 SET svcmode=49 if "%1" == "-manual" SET svcmode=-manual50 if "%1" == "-auto" SET svcmode=-auto51
52
53 rem 設(shè)置JAVA_OPTS54 set JAVA_OPTS=%JAVA_OPTS% -Djava.class.path="%BASE_PATH%\UDPServer-0.0.1-SNAPSHOT.jar"55 set JAVA_OPTS=%JAVA_OPTS% %JVM_MEMORY%56
57 rem 設(shè)置startstop58 SET START_STOP=-start com.dsdl.server.Main59
60
61 rem 設(shè)置Log文件路徑62 set OUT_ERR=-out "%BASE_PATH%\service_out.log" -err "%BASE_PATH%\service_err.log"63
64 rem 設(shè)置desp65 set DESP=-description "UdpServer Service"66
67 rem 設(shè)置執(zhí)行命令行68 set runcmd="%JSEXE%" -install UDPSERVER69 set runcmd=%runcmd% "%jvmdll%"70 set runcmd=%runcmd% %JAVA_OPTS%71 set runcmd=%runcmd% %START_STOP%72 set runcmd=%runcmd% %OUT_ERR%73 set runcmd=%runcmd% -current74 set runcmd=%runcmd% "%BASE_PATH%"75 set runcmd=%runcmd% %svcmode%76 set runcmd=%runcmd% -overwrite77 set runcmd=%runcmd% -startup 678 set runcmd=%runcmd% %DESP%79 echo %runcmd%80
81 rem 執(zhí)行安裝命令82 %runcmd%83
84 rem 啟動(dòng)服務(wù)85 net start UDPSERVER86 if ERRORLEVEL 1 goto js_error87
88 goto end89
90 :no_java91 @echo . No java Evn92 goto error_exit93
94 :no_peer95 @echo . jar is not exist96 goto error_exit97
98
99 :no_jsexe100 @echo . JavaService.exe is not exist101 goto error_exit102
103
104 :js_error105 @echo . UDPSERVER error106 goto error_exit107
108 :error_exit109
110 @echo .111 @echo . install fail,can not make UDPServer-0.0.1-SNAPSHOT install for Windows Service112 @echo .113 @echo . mingling geshi:114 @echo .115 @echo . %~n0 [-auto / -manual] [-np]116 @echo .117 @echo . qizhong:118 @echo . -auto (默認(rèn)) or -manual 參數(shù)說明了服務(wù)的啟動(dòng)模式:自動(dòng)或者手動(dòng)119 @echo . -np 批處理命令執(zhí)行完畢后不暫停120 @echo .121 @echo . 比如:122 @echo . %~n0 -auto -np123
124 :end125 ENDLOCAL126 @echo .127 if "%2" NEQ "-np" @pause
總結(jié)
以上是生活随笔為你收集整理的java 打包成服务_maven javaProject打包发布成服务的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java dh算法_dh密钥交换算法ja
- 下一篇: java 单引号的字符串类型_Java程