Package the jar package into a service program under--windows

Source: Internet
Author: User

Http://www.cppblog.com/aurain/archive/2014/01/23/205534.aspx

1 Prepare

Using the tool Procrun (http://commons.apache.org/proper/commons-daemon/procrun.html), (http://archive.apache.org/dist/ commons/daemon/binaries/windows/), Tomcat also uses it as a service program. The latest version is Commons-daemon-1.0.15-bin-windows.zip (update 2013-04-02 14:03), 32-bit system use directory under the default prunsvr.exe,64 bit system amd64\ Prunsvr.exe.

Assuming that the name of the jar package that needs to be deployed is Myservice.jar, we first create the directory myservice, copy the Myservice.jar and Prunsvr.exe to the MyService directory, and rename Prunsvr.exe to MyService.exe. If Myservice.jar needs to use a configuration file, such as a configuration file in the Conf directory, then the Conf directory needs to be copied to the MyService directory.

2 Installation Scripts

@echo off

SET pr_path=%cd%

SET Pr_exe=myservice.exe

SET pr_service_name= MyService

SET pr_display_name= MyService

SET pr_description= MyService for Xxx,copyright XXXXXX.

SET pr_jar= Myservice.jar

SET Start_class=com.xxx.myservice

SET Start_method=main

SET Stop_class=java.lang.system

SET Stop_method=exit

SET stop_params=0

%pr_path%\%pr_exe%//is//%pr_service_name%--displayname= "%pr_display_name%"--description= "%PR_DESCRIPTION%"-- Install= "%pr_path%\%pr_exe%"--jvmms=2000--jvmmx=2000--jvmss=1024 ++dependson=mssqlserver--Jvm=auto--Startup= Auto--STARTMODE=JVM--startclass=%start_class%--startmethod=%start_method%--STOPMODE=JVM--StopClass=%STOP_CLASS %--stopmethod=%stop_method% ++stopparams=%stop_params%--classpath= "%pr_path%\%pr_jar%"

%pr_path%\%pr_exe%//es//%pr_service_name%

@echo on

3 Unload Script

@echo off

SET pr_path=%cd%

SET Pr_service_name=myservice

SET pr_exe= MyService.exe

%pr_path%\%pr_exe%//ds//%pr_service_name%

@echo on

4 Prunsvr parameter Description

PRUNSVR is a command-line tool that can be used to package ordinary programs into service programs, not only for Java programs, but also for other EXE executables.

PRUNSVR command Format//xx[//servicename].

Main command line

TS Console mode operation

is installation service

ES Start-up service

SS Stop Service

DS Delete Service

Main command line arguments

command-line parameter prefixes are--。 If the prefix is + +, then these parameters are appended to the option that already exists.

Description of the--description service name (maximum 1024 characters)

--displayname the name of the service display

--install Procrun.exe//rs//servicename installation image

--startup service startup mode, auto Auto or manual manual, default to Manual

The--type service type can be an interactive desktop program interactive. Use and this option are limited to the local system account

Other services that the ++dependson service needs to rely on. Depending on the service use # or; Character segmentation

--classpath for Java classes, set the jar package path

--jvmms Initial memory pool, unit MB

--JVMMX Maximum memory pool, Unit MB

--JVMSS thread stack, per KB

Please refer to the official Help documentation for more assistance.

Package the jar package into a service program under--windows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.