日期:2014-05-17  浏览次数:21049 次

将Java控制台应用作为windows服务
install64.bat
@echo off
set "BASEDIR=%CD%"
set "log4j_conf=%CD%\conf\log4j.properties"


echo install uCMDB CompanyCode 
set "LIB_PATH=%BASEDIR%\lib"

set "CLASSPATH=%BASEDIR%\CompanyCode.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\commons-collections-3.2.1.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\commons-configuration-1.6.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\commons-io-1.4.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\commons-lang-2.5.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\commons-logging-1.1.1.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\commons-pool-1.5.4.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\http_client.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\jaxrpc-api.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\jsch-0.1.44.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\jtidy-r938.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\log4j-1.2.16.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\mail.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\mdds.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\companySearch.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\oc4jclient.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\ojdbc14.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\opencsv-2.2.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\orasaaj.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\relaxngDatatype.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\wsclient.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\xmlparserv2.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\xsdlib.jar"
set "CLASSPATH=%CLASSPATH%;%LIB_PATH%\ucmdbCommons.jar"

set "SRV=%BASEDIR%\tools\prunsrvamd64.exe"
if "%JVM%" == "" goto findJvm
if exist "%JVM%" goto foundJvm
:findJvm
set "JVM=C:\Program Files\Java\jre6\bin\server\jvm.dll"
if exist "%JVM%" goto foundJvm
set "JVM=C:\Program Files\Java\jre6\bin\client\jvm.dll"
if exist "%JVM%" goto foundJvm
echo can not find jvm.dll automatically,
echo please use COMMAND to localation it 
echo for example : set "JVM=C:\Program Files\Java\jre6\bin\server\jvm.dll"
echo then install service
goto end
:foundJvm

"%SRV%" //IS//uCMDBCompanyCode --DisplayName="uCMDB CompanyCode"  ++JvmOptions="-Dlog4j.configuration=file:/%log4j_conf%" 	"--Classpath=%CLASSPATH%"   "--Install=%SRV%"   "--Jvm=%JVM%" --Startup=auto --StartMode=jvm --StopMode=jvm "--StartPath=%BASEDIR%" --StartClass=hp.es.ucmdb.ccv.Main --StartMethod=windowsService --StartParams=start "--StopPath=%BASEDIR%" --StopClass=hp.es.ucmdb.ccv.Main --StopMethod=windowsService --StopParams=stop "--LogPath=%BASEDIR%\log" --StdOutput=auto --StdError=auto  
  

:end


start.bat
@echo off

set BASEDIR=%CD%

echo start uCMDBCompanyCode Service
sc start uCMDBCompanyCode
rem start %BASEDIR%\tools\prunmgr.exe //MR//uCMDBCompanyCode