---
title: "Java Service Wrapper工具把Java程序转换为Windows服务小结(新版3.5.17)"
author: "TechBirds"
date: "2013-04-14T12:22:00Z"
tags: []
slug: "java-service-wrapper-java-windows-3-5-17"
draft: false
lastmod: "2013-04-27T15:02:06Z"
id: 1855912
url: "https://techbirds.iteye.com/blog/1855912"
---

大致步骤相同，在文件配置及需要的文件有所不同.

下载地址：[http://wrapper.tanukisoftware.com/doc/english/download.jsp](http://wrapper.tanukisoftware.com/doc/english/download.jsp)

步骤：

# 1.建立目录

建立一个目录比如：D盘server文件夹里面建立bin、conf、logs、lib文件夹。

# 2.拷贝所需文件到先前建立的目录

将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和wrapper-license.conf拷贝至server/conf目录里去掉后缀名in  
再将wrapper\_home/lib/目录里面的wrapper.jar和wrapper.dll拷贝至server/lib目录里面

# 3.配置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此处是的改下：

wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp

否则可以执行，但会无故停止。

Advice:  
ADVICE | wrapper | 2013/04/14 12:59:56 | The Wrapper consists of a native component as well as a set of classes  
ADVICE | wrapper | 2013/04/14 12:59:56 | which run within the JVM that it launches. The Java component of the  
ADVICE | wrapper | 2013/04/14 12:59:56 | Wrapper must be initialized promptly after the JVM is launched or the  
ADVICE | wrapper | 2013/04/14 12:59:56 | Wrapper will timeout, as just happened. Most likely the main class  
ADVICE | wrapper | 2013/04/14 12:59:56 | specified in the Wrapper configuration file is not correctly initializing  
ADVICE | wrapper | 2013/04/14 12:59:56 | the Wrapper classes:  
ADVICE | wrapper | 2013/04/14 12:59:56 | com.techbirds.main.CallHtmlTimer  
ADVICE | wrapper | 2013/04/14 12:59:56 | While it is possible to do so manually, the Wrapper ships with helper  
ADVICE | wrapper | 2013/04/14 12:59:56 | classes to make this initialization processes automatic.  
ADVICE | wrapper | 2013/04/14 12:59:56 | Please review the integration section of the Wrapper's documentation  
ADVICE | wrapper | 2013/04/14 12:59:56 | for the various methods which can be employed to launch an application  
ADVICE | wrapper | 2013/04/14 12:59:56 | within the Wrapper:  
ADVICE | wrapper | 2013/04/14 12:59:56 | http://wrapper.tanukisoftware.com/doc/english/integrate.html  
ADVICE | wrapper | 2013/04/14 12:59:56 | ----------------------------------------

ps：如果这个没配对，会导致安装的服务，启动出错1503。相当坑爹。

#执行类

wrapper.app.parameter.1=com.techbirds.main.CallHtmlTimer

#服务名

wrapper.ntservice.name=server  
\# Display name of the service  
wrapper.ntservice.displayname=server  
#服务描述  
wrapper.ntservice.description=receive message

其他的配置根据你的需要改变即可

# 4.控制台执行服务

对以上配置的App.bat进行测试，运行App.bat，dos窗口中显示；

5.生成win 服务

# 对以上配置的服务进行测试，运行server/bin/InstallApp-NT.bat将把你的应用（此处为server）安装到Win32系统服务中了。

bin/App.bat 控制台方式运行程序

bin/InstallApp-NT.bat 安装服务

bin/UninstallApp-NT.bat删除服务