Installing a jar package into a Windows service using Java Service Wrapper

Source: Internet
Author: User

To run the jar package on Windows, you need to run the jar package in the working directory using the command line, which will cause a command-line window to appear. And this command-line window may be accidentally shut down, and the server after the start of the need to manually click to open.

For some service programs, we need to deploy them as Windows services and start automatically when the system starts.

I used YAJSW in front of me, please refer to my blog: http://www.cnblogs.com/kxxx/p/6744309.html

But this time on another server processing, after the installation of the service can not open, the service every time to find the specified file errors, tried for a long time has not been done, have to shift the vision to another software Java Service Wrapper.

Before I use it, I refer to the following article:

http://blog.csdn.net/fly_sky520/article/details/8809325

http://blog.csdn.net/lqclh502/article/details/51557015

After reference, ready to download the file: http://wrapper.tanukisoftware.com/doc/english/download.jsp

Because my server is 64-bit, in the download time found that there is no free version of the 64-bit, but also worry about the other 2 versions to charge, it did not download the other 2 versions, looking for cracked version of the web, and finally downloaded on this site:

https://www.krenger.ch/blog/java-service-wrapper-3-5-14-for-windows-x64/

The version I downloaded is 3.5.14.

Then start the configuration:

1. Create a new folder on my server named JAR_JSW.

2. Unzip the downloaded zip package.

3. Create a new bin, Conf, Lib, logs folder under the new folder JAR_JSW, and copy the jar package that needs to be started to the JAR_JSW directory, my Jar package is: Processapp.jar

4. Copy the files from the Src\bin folder to the new Jar_jsw/bin folder. and remove all files in the suffix. Also put the Wrapper.exe under the bin in the Unpacked folder under the new bin

5. Copy the files in the Src\conf folder to the new Conf folder. Remove the in suffix, in fact there is only one file, namely wrapper.conf.

6. Put the Wrapper.jar and Wrapper.dll in the Unpacked folder into the new Lib. Also place the third-party jar package required to start the jar package.

7. Start configuring the wrapper.conf file. See other articles for configuration options.

8. After the configuration, click App.bat under the Bin folder to test, if you can have normal results in the console, it indicates that the configuration is correct. Then click Installapp-nt.bat to install the service, or click Uninstallapp-nt.bat Uninstall service. After the service is successfully installed, you can see it in Window service management.

Note: My jar package uses System.getproperty ("User.dir") to get the working directory, according to the default settings, I started the program to error, always reported missing files. So I am on the Internet to see if the JSW has modified the working directory parameters, and finally the reference:

Https://wrapper.tanukisoftware.com/doc/english/properties.html

Wrapper.working.dir This setting is found, so refer to its settings: https://wrapper.tanukisoftware.com/doc/english/prop-working-dir.html

When the working directory is modified, the corresponding parameters such as Classpath will need to be changed, as shown in the parameters. I modified everything after OK.

At this point, I wrapped the jar package into a Windows service complete.

Written in the back, I found that ACTIVEMQ is also a service installed using this method.

Here is my configuration file:

encoding=utf-8# Configuration files must begin with a line specifying the encoding# of the The file.#********************************************************************# Wrapper License Properties (ignored by Community Edition) #********************************************************************# Professional and Standard Editions of the Wrapper require a valid# License Key to start. Licenses can purchased or a trial license# requested on the following pages:# http://Wrapper.tanukisoftware.com/purchase# http://wrapper.tanukisoftware.com/trial# Include file problems can debugged by removing the first'#'#   fromThe following line:# #include. debug# the Wrapper would look forEither of the following optional files fora# valid License Key. License Key Properties can optionally be included# directlyinch  Thisconfiguration file. #include ./conf/wrapper-license.conf#include ./conf/wrapper-license-%wrapper_host_name%. conf# The following property would output information about which License Key (s) # is being found, and can aidinchresolving any licensing problems. #wrapper. License.debug=true#********************************************************************# Wrapper localization#********************************************************************# Specify the locale which the Wrapper should use. bydefaultThe system# locale isused. #wrapper. Lang=en_US # en_US or ja_jp# specify the location of the Wrapper's language resources. If these is# Missing, the Wrapper woulddefaultTo the en_US locale.wrapper.lang.folder=.. /lang#********************************************************************# Wrapper Java properties#********************************************************************# java application# Locate the Java binary on the system PATH:wrapper.java.command=c:\program Files\java\jdk1.8.0_25/bin/java# Specify a specific Java binary:#Set. java_home=/java/Path#wrapper.java.command=%java_home%/bin/java# tell the Wrapper to log the full generated Java command line. #wrapper. Java.command.loglevel=info# Java Mainclass. ThisclassMust implement the WrapperlistenerInterface# or guarantee that the Wrappermanagerclass  isinitialized. helper# classes is provided to Do  This  forYou . See the integration section# of the documentation forDetails.wrapper.java.mainclass=org.tanukisoftware.wrapper.wrappersimpleapp# Java Classpath (include Wrapper.jar) AddclassPath elements as# needed starting from 1#wrapper. Java.classpath .1=.. /lib/Wrapper.jar#wrapper.java.classpath.2=.. /Processapp.jar#wrapper.java.classpath.3=.. /lib/*After #更改了working. Dir. The path will change wrapper.working.dir=. /wrapper.java.classpath.1=lib/wrapper.jarwrapper.java.classpath.2=processapp.jarwrapper.java.classpath.3=lib/*  # java Library Path (location of Wrapper.DLL or libwrapper.so) wrapper.java.library.path.1=lib# Java Bits.  On applicable platforms, tells the JVM to run in or 64-bit mode.wrapper.java.additional.auto_bits=true# Java additional parameterswrapper.java.additional.1=# Initial Java Heap size (in MB) #wrapper. java.initmemory=3# Maximum java Heap Size (i  n MB) #wrapper. java.maxmemory=64# application parameters. ADD parameters as needed starting from 1wrapper.app.parameter.1=com.el.cardata.processapp.hcappstart#*************** # Wrapper Logging properties#******************************* # enables Debug output from the wrapper.# wrapper.debug=true# Format of output for th  E 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/WR  apper.log#wrapper.pidfile=bin/wrapper.pid#wrapper.java.pidfile=bin/java.pid# 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, the log file would be allowed to grow 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 = megabytes.wrapper.logfile.maxsize=0# Maximum number of rolled log files which would 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 General Properties#********************************************************************# allow for the use of non-contiguous Numbered propertieswrapper.ignore_sequence_gaps=true# do not start if the PID file already exists.wrapper.pidfile.strict =true# Title to use when running as a consolewrapper.console.title=cj_messagepro#************************************* # Wrapper JVM checks#************************************************************* # Detect deadlocked Threads in the JVM. (Requires standard Edition) wrapper.check.deadlock=truewrapper.check.deadlock.interval= 60wrapper.check.deadlock.action=restartwrapper.check.deadlock.output=full# out of Memory detection.# (simple match) wrapper.filter.trigger.1000=java.lang.outofmemoryerror# (only match text on stack traces If-xx:+printclasshistogram is being used.) #wrapper. Filter.trigger.1000=exception in Thread "*" Java.lang.outofmemoryerror#wrapper.filter.allow_ Wildcards.1000=truewrapper.filter.action.1000=restartWrapper.filter.message.1000=the JVM has run out of memory.#********************************************************* # Wrapper Email notifications. (Requires Professional Edition) #********************************************************************# Common Event Email settings. #wrapper. event.default.email.debug=true#wrapper.event.default.email.smtp.host=<smtp_host># Wrapper.event.default.email.smtp.port=25#wrapper.event.default.email.subject=[%wrapper_hostname%:%wrapper_name %:%wrapper_event_name%] EVENT Notification#wrapper.event.default.email.sender=<sender email># Wrapper.event.default.email.recipient=<recipient email># Configure The log attached to event emails.# wrapper.event.default.email.attach_log=true#wrapper.event.default.email.maillog.lines=50# wrapper.event.default.email.maillog.format=lptm#wrapper.event.default.email.maillog.loglevel=info# Enable Specific event emails. #wrapper. Event.wrapper_start.email=true#wrapper.event.jvm_prelaunch.email=true#wrapper.event.jvm_start.email=true#wrapper.event.jvm_started.email=true#wrapper.event.jvm_deadlock.email=true# wrapper.event.jvm_stop.email=true#wrapper.event.jvm_stopped.email=true#wrapper.event.jvm_restart.email=true# wrapper.event.jvm_failed_invocation.email=true#wrapper.event.jvm_max_failed_invocations.email=true# Wrapper.event.jvm_kill.email=true#wrapper.event.jvm_killed.email=true#wrapper.event.jvm_unexpected_exit.email= true#wrapper.event.wrapper_stop.email=true# Specify custom mail contentwrapper.event.jvm_restart.email.body=the JVM Was restarted.\n\nplease check in its status.\n#******************************************************************* *# Wrapper Windows nt/2000/xp Service properties#******************************************************************  **# warning-do not modify all of these properties when a application# using this configuration file have been installed  As a service.# please uninstall the service before modifying this section. the# service can then be reinstalled.# name of the servicewrapper.name=cj_messagepro# Display name of the servicewrapper.displayname=cj_messagepro#  Description of the servicewrapper.description=cj_messagepro# Service dependencies.  ADD dependencies as needed starting from 1wrapper.ntservice.dependency.1=# Mode on which the service is installed. Auto_start, Delay_start or demand_startwrapper.ntservice.starttype=auto_start# allow the service to interact with the DES Ktop.wrapper.ntservice.interactive=false

Installing a jar package into a Windows service using Java Service Wrapper

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.