Registering Java programs as a system service

Source: Internet
Author: User
Tags wrapper

Are you looking for a way to register a Java program as a system service? Try the Java Service Wrapper This tool, you can download your favorite version from this website: http://wrapper.tanukisoftware.org/, Java Service Wrapper offers a version of the popular operating system available on the market.

There are three ways to use wrapper to register Java programs as System services:

The first is to use Wrappersimpleapp to run your program, which is the easiest and official way to use it, but it may change your program, which is good if you start thinking about it at the beginning of the project. Like JBoss is also used in this way.

The second approach is to implement functionality using the Wraperstartstopapp class, which is suitable for applications that are responsible for starting the service through the ClassA class and CLASSB classes to stop the service.

I'm using a third way, which benefits from minor changes to the program, just let your startup class implement the Wrapperlistener interface and implement the start (string[] args in the interface and the Stop (String [] args) method. Then it starts with Wrappermanager. Other configurations, such as the full name of the main class to run, the Java classpath, the path dependent on the Java library, and the name of the service display, can be configured by the configuration file conf/wrapper.conf, which is relatively flexible, like the RCP project I'm currently working on has an automatic update function, Newer plug-ins than those of the original version of the plugin to update, although it will periodically delete those expired plug-ins, but sometimes there will be delays, then configure the Java classpath configuration files must also link to the latest plug-in address, I manage this wrapper.confg file through a Java class, and if there are newer plug-ins that get the latest plugin path through Java classes, write that information to the Wrapper.confg file, which guarantees that the classpath in the configuration file is up to date.

The following is the structure of the program:

The home page describes the configuration of wrapper.conf, which is a common Java property file format,

Wrapper.java.command=java: Specifies the Java to run, if you do not want to set environment variables, you can also specify the JDK bin file path

Wrapper.java.mainclass=test. Main: Specifies the class to run, which must implement the start and stop methods in the Wrapperlistener interface and interface, and initialize the service through the Wrappermanager class. If there is an inability to obtain JVM information during the start of the service, it may be an interface implementation issue.

Related Article

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.