JavaService空格问题

想用JavaService把客户端程序封装为windows的服务,官方带了一个简单例子。发现如果JDK路径中有空格,则服务注册成功,但是启动失败。官方给的bat内容:

 

@echo off

@echo .
@echo . TestSampleService.bat - test JavaService executable using SampleService.jar
@echo .


setlocal
@rem note that if JVM not found, service 'does not report an error' when startup fails, although event logged
if "%JAVA_HOME%" == "" set JAVA_HOME=d:\j2sdk1.4.2_10\jre
set JVMDIR=%JAVA_HOME%\jre\bin\server
set JSBINDIR=%CD%
set JSEXE=%JSBINDIR%\JavaService.exe
set SSBINDIR=%JSBINDIR%


@echo . Using following version of JavaService executable:
@echo .
%JSEXE% -version
@echo .


@echo Installing sample service... Press Control-C to abort
@pause
@echo .
%JSEXE% -install SampleService %JVMDIR%\jvm.dll -Djava.class.path=%SSBINDIR%\SampleService.jar -Xms16M -Xmx32M -start org.objectweb.javaservice.test.SampleService -params start memory -stop org.objectweb.javaservice.test.SampleService -method serviceStop -out %JSBINDIR%\stdout.log -err %JSBINDIR%\stderr.log -current %JSBINDIR% -manual -description "Sample Java Service"
@echo .


@echo Starting sample service... Press Control-C to abort
@pause
@echo .
net start SampleService
@echo .


@echo Stopping sample service... Press Control-C to abort
@pause
@echo .
net stop SampleService
@echo .


@echo Un-installing sample service... Press Control-C to abort
@pause
@echo .
%JSEXE% -uninstall SampleService
@echo .


@echo End of script
@pause

 

 网上一般简单说路径中不能有空格,其实主要是dos里面不识别。加个引号就解决了

set JAVA_HOME="C:\Program Files\jdk1.5.0_15"

你可能感兴趣的:(JavaService空格问题)