JavaService----Java程序部署成windows服务

JavaService

目录

JavaService

官方网址

为什么选择JavaService

JavaService如何使用

JavaService参数说明

 相关参数的作用说明如下

项目常用写法

参数解释说明


官方网址

http://javaservice.ow2.org/index.html

为什么选择JavaService

  1. JavaService是一个开源免费的软件,大小只有100多kB,区分32位,64位jdk,可以跟据需要下载,
  2. 市面上也有其他的将java程序打成windows服务的软件,比如Java Service Wrapper,,但是64位jdk版本的是需要收费的,而目前大部分java程序都是在64为jdk上运行,因此有局限性

JavaService如何使用

JavaService参数说明

JavaService一共提供了8个参数可供选择,其中我们只需要关心安装NT服务的-install参数和卸载NT服务的-uninstall参数。
使用-install参数安装NT服务时还需要提供与服务相关的其它一些参数,其命令格式如下:

JavaService -install service_name jvm_library [jvm_options]
        -start start_class [-method start_method] [-params (start_parameters)]
        [-stop start_class [-method stop_method] [-params (stop_parameters)]]
        [-out out_log_file] [-err err_log_file]
        [-current current_dir]
        [-path extra_path]
        [-depends other_service]
        [-auto | -manual]
        [-shutdown seconds]
        [-user user_name -password password]
        [-append | -overwrite]
        [-startup seconds]
        [-description service_desc]

 相关参数的作用说明如下

 service_name: The name of the service.
 jvm_library:  The location of the JVM DLL used to run the service.
 jvm_option:   An option to use when starting the JVM, such as:
                       "-Djava.class.path=c:/classes" or "-Xmx128m".
 start_class:  The class to load when starting the service.
 start_method: The method to call in the start_class. default: main
 start_parameters:Parameter(s) to pass in to the start_method.
 stop_class:   The class to load when stopping the service.
 stop_method:  The method to call in the stop_class. default: main
 stop_parameters:      Parameter(s) to pass in to the stop_method.
 out_log_file: A file to redirect System.out into. (gets overwritten)
 err_log_file: A file to redirect System.err into. (gets overwritten)
 current_dir:  The current working directory for the service.
                       Relative paths will be relative to this directory.
 extra_path:   Path additions, for native DLLs etc. (no spaces)
 other_service:        Single service name dependency, must start first.
 auto / manual:        Startup automatic (default) or manual mode.
 seconds:      Java method processing time (startup:sleep, shutdown:timeout).
 user_name:    User specified to execute the service (user@domain).
 password:     Password applicable if user specified to run the service.
 append / overwrite:   Log file output mode, append (default) or overwrite.
 service_desc: Text describing installed service (quoted string, max 1024).

项目常用写法

JavaService.exe -install ECService "%JAVA_HOME%/jre/bin/server/jvm.dll" -Djava.ext.dirs="%JAVA_HOME%/jre/lib/ext" -Xms128m -Xmx512m -Djava.class.path="JAVA_HOME%/lib/tools.jar;c:/ECService/ec.jar" -start com.ecservice.ECService -out "%CD%/out.log" -err "%CD%/err.log" -current "%CD%" -auto

参数解释说明

JavaService.exe                           //JavaService程序,自己选32位还是64位 
-install ECService                        //服务名,根据自己的需要取,比如ECService
"%JAVA_HOME%/jre/bin/server/jvm.dll"      //jdk环境下的配置,基本固定写法-Djava.ext.dirs="%JAVA_HOME%/jre/lib/ext"                   //扩展依赖包路径
-Xms128m -Xmx512m                         //程序堆栈内存设置
-Djava.class.path="%JAVA_HOME%/lib/tools.jar;c:/ECService/ec.jar"//程序依赖包,配置文件等,比如lib,config
-start com.ecservice.ECService            //系统启动的主类,一般main方法所在类的全路径
-out "%CD%/out.log"  -err "%CD%/err.log"  //日志,一般不使用,跟项目自带的log4j2不矛盾,但会有两套日志,一般用于错误排查
-current "%CD%"                           //项目运行的当前目录 
-auto                                     //自动
-Dfile.encoding=utf-8                     //编码格式
-DEBUG_ARGS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=12345  //dubeg模式

 

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值