Java Service Wrapper可以把Java应用程序安装成一个Windows NT服务或Unix Daemon.它同时还为应用程序提供日记功能,灵活的配置,可靠的运行性能,按需求重新启动,简化应用程序的安装等。下面一个例子演示:
1. java 应用程序所在的目录:
E:\netbeansProjects\loganalysis\build
java class的目录: E:\netbeansProjects\loganalysis\build\bin
2.下载Java Service Wrapper :http://wrapper.tanukisoftware.org/
把App.bat ; InstallApp-NT.bat ; UninstallApp-NT.bat ; wrapper.exe 复制到 E:\netbeansProjects\loganalysis\build\bin
把wrapper.conf 复制到E:\netbeansProjects\loganalysis\build\conf
把 wrapper.dll ;wrapper.jar ; 复制到 E:\netbeansProjects\loganalysis\build\lib
注意:如果你有用通过集成身份连接sql server ,把sqljdbc_auth.dll也copy到lib下面(或者放入WINDOWS下面的jdbc)
3.修改wrapper.conf
#********************************************************************
# Wrapper Properties
#********************************************************************
# Java Application
wrapper.java.command=java
#Java Application 如果没设置java环境变量
#wrapper.java.command=D:\Program Files\Java\jdk1.6.0_10\bin\java
# Java Main class. This class must implement the WrapperListener
interface
# or guarantee that the WrapperManager class is initialized. Helper
# classes are provided to do this for you. See the Integration
section
# of the documentation for details.
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
wrapper.java.classpath.1=../lib/wrapper.jar
wrapper.java.classpath.2=../bin/.
#你的应用程序需要引入的第三方jar
wrapper.java.classpath.3=../bin/ant-1.6.5.jar
wrapper.java.classpath.4=../bin/sqljdbc.jar
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=../lib
# Java Additional Parameters
wrapper.java.additional.1=-Dprogram.name=NB.bat
# Initial Java Heap Size (in MB)
#wrapper.java.initmemory=3
# Maximum Java Heap Size (in MB)
#wrapper.java.maxmemory=64
# Application parameters. Add parameters as needed starting from 1 你的应用程序的main Class
wrapper.app.parameter.1=com.fg114.log.service.EggTimer
#********************************************************************
# Wrapper Logging Properties
#********************************************************************
# Format of output for the console. (See docs for formats)
wrapper.console.format=PM
# Log Level for console output. (See docs for log levels)
wrapper.console.loglevel=INFO
# Log file to use for wrapper output logging.
wrapper.logfile=../logs/wrapper.log
# Format of output for the log file. (See docs for formats)
wrapper.logfile.format=LPTM
# Log Level for log file output. (See docs for log levels)
wrapper.logfile.loglevel=INFO
# Maximum size that the log file will be allowed to grow to before
# the log is rolled. Size is specified in bytes. The default value
# of 0, disables log rolling. May abbreviate with the 'k' (kb) or
# 'm' (mb) suffix. For example: 10m = 10 megabytes.
wrapper.logfile.maxsize=0
# Maximum number of rolled log files which will be allowed before old
# files are deleted. The default value of 0 implies no limit.
wrapper.logfile.maxfiles=0
# Log Level for sys/event log output. (See docs for log levels)
wrapper.syslog.loglevel=NONE
#********************************************************************
# Wrapper Windows Properties
#********************************************************************
# Title to use when running as a console
wrapper.console.title=Ann test
#********************************************************************
# Wrapper Windows NT/2000/XP Service Properties
#********************************************************************
# WARNING - Do not modify any of these properties when an application
# using this configuration file has been installed as a service.
# Please uninstall the service before modifying this section. The
# service can then be reinstalled.
# Name of the service
wrapper.ntservice.name=Ann test
# Display name of the service
wrapper.ntservice.displayname=Ann test
# Description of the service
wrapper.ntservice.description=Ann test
# Service dependencies. Add dependencies as needed starting from 1
wrapper.ntservice.dependency.1=
# Mode in which the service is installed. AUTO_START or DEMAND_START
wrapper.ntservice.starttype=AUTO_START
# Allow the service to interact with the desktop.
wrapper.ntservice.interactive=fal
4.双击 InstallApp-NT.bat 安装为wins服务。
UninstallApp-NT.bat为删除wins服务。
posted on 2009-05-11 14:32
冰是没有未来的,因为它的永恒 阅读(589)
评论(0) 编辑 收藏