首先下载java service wrapper工具
http://sourceforge.net/project/showfiles.php?group_id=39428
步骤:
1、解压缩java service wrapper包,假设目录为:wrapper_home
2、建立一个目录比如:D盘server文件夹里面建立bin、conf、logs、lib文件夹。
3、将wrapper_home/bin目录里wrapper.exe
将wrapper_home/src/bin目录里App.bat.in
将wrapper_home/src/bin目录里InstallApp-NT.bat.in
将wrapper_home/src/bin目录里UninstallApp-NT.bat.in
统一拷贝至server/bin目录里,并去掉后缀名in。
将wrapper_home/src/conf目录wrapper.conf.in拷贝至server/conf目录里去掉后缀名in
再将wrapper_home/lib/目录里面的wrapper.jar和wrapper.dll拷贝至server/lib目录里面
4、将你的应用程序打成jar包后放入server/lib目录里面,如果程序依赖第三方架包,同样将jar包放入该目录下。
5、配置server/conf/wrapper.conf文件。
主要修改以下几项即可:
#你的JVM位置:
wrapper.java.command=%JAVA_HOME%\bin\java
#classpath:里面添加上你要执行的应用程序jar,以及依赖的第三方jar,有多个依次类推
wrapper.java.classpath.1=../lib/应用程序.jar
wrapper.java.classpath.2=../lib/wrapper.jar
wrapper.java.classpath.3=../bin/第三方.jar
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=../lib
#MAIN CLASS 此处决定了使用Java Service Wrapper的方式
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
上面红色字体不能修改成你的执行程序路径比如
service.server.Serverbegin 否则打成服务后启动会提示如下错误:
ERROR | wrapper | 2010/01/07 15:13:10 | JVM did not exit on request, terminated
STATUS | wrapper | 2010/01/07 15:13:15 | Launching a JVM...
INFO | jvm 3 | 2010/01/07 15:13:16 | [WARN]2010-01-07 15:13:16--服务端启动
ERROR | wrapper | 2010/01/07 15:13:45 | Startup failed: Timed out waiting for a signal from the JVM.
ADVICE | wrapper | 2010/01/07 15:13:45 |
ADVICE | wrapper | 2010/01/07 15:13:45 | ------------------------------------------------------------------------
ADVICE | wrapper | 2010/01/07 15:13:45 | Advice:
ADVICE | wrapper | 2010/01/07 15:13:45 | The Wrapper consists of a native component as well as a set of classes
ADVICE | wrapper | 2010/01/07 15:13:45 | which run within the JVM that it launches. The Java component of the
ADVICE | wrapper | 2010/01/07 15:13:45 | Wrapper must be initialized promptly after the JVM is launched or the
ADVICE | wrapper | 2010/01/07 15:13:45 | Wrapper will timeout, as just happened. Most likely the main class
ADVICE | wrapper | 2010/01/07 15:13:45 | specified in the Wrapper configuration file is not correctly initializing
ADVICE | wrapper | 2010/01/07 15:13:45 | the Wrapper classes:
ADVICE | wrapper | 2010/01/07 15:13:45 | service.hl7Server.HuaHaiHl7Server
ADVICE | wrapper | 2010/01/07 15:13:45 | While it is possible to do so manually, the Wrapper ships with helper
ADVICE | wrapper | 2010/01/07 15:13:45 | classes to make this initialization processes automatic.
ADVICE | wrapper | 2010/01/07 15:13:45 | Please review the integration section of the Wrapper's documentation
ADVICE | wrapper | 2010/01/07 15:13:45 | for the various methods which can be employed to launch an application
ADVICE | wrapper | 2010/01/07 15:13:45 | within the Wrapper:
ADVICE | wrapper | 2010/01/07 15:13:45 | http://wrapper.tanukisoftware.org/doc/english/integrate.html
#你的Java应用类,
wrapper.app.parameter.1= service.Server.Serverbegin
# 服务名
wrapper.ntservice.name=server
# Display name of the service
wrapper.ntservice.displayname=server
# 服务描述
wrapper.ntservice.description=receive message
其他的配置根据你的需要改变即可
6. 对以上配置的App.bat进行测试,运行App.bat,dos窗口中显示;
7. 对以上配置的服务进行测试,运行server/bin/InstallApp-NT.bat将把你的应用(此处为server)安装到Win32系统服务中了。
8. 打开控制面板-管理程序-服务,看到server已经在系统服务中了,其他用法就与我们熟悉的Windows服务一样了。
bin/App.bat 控制台方式运行程序
bin/InstallApp-NT.bat 安装服务
bin/UninstallApp-NT.bat 删除服务
posted on 2010-01-18 13:10
朔望魔刃 阅读(3403)
评论(2) 编辑 收藏 所属分类:
各种配置