Java programs run as a service overview

Source: Internet
Author: User
Tags wrapper

I. Overview

 Using the Java language to develop applications, under the Windows platform, there are generally 3 types of applications:

   1. Web Apps . Most web Apps run as war packages in web containers, such as Tomcat,jetty.

  2. Desktop apps. Desktop apps typically run as jar packages or EXE files.

  3. Background service app. Background service apps are typically made into jar packages and then run using the command line (such as Java-jar Xxx.jar).

Two. What is a Windows service?

Microsoft Windows Services (that is, previous NT services) enable you to create executable applications that can run for long periods of time in their own Windows sessions.    These services can be started automatically when the computer starts, can be paused and restarted, and does not display any user interface. This service is ideal for use on a server, or at any time, in order not to affect other users working on the same computer that require long-running functionality. You can also run a service in a different security context than a specific user account or a default computer account that is a logged-on user.

Three. Why should the Java program run as a service?

If you run a Java program using the command line, you can run the command as a script (such as a bat script), but the command line is inconvenient, such as the command Line window cannot be closed, the shutdown is stopped, so the maintenance personnel are prone to misoperation (close the window to stop the program), if the server is down or other reasons, Programs often fail to start automatically when the server restarts. Under Windows, many programs run as a service, which is also in line with Windows management. Therefore, it is recommended to use the service form operation, easy to operate.

Four. How do I make a Java program run as a service?

  1. Java Service Wrapper is currently the industry's most well-known and most mature solution, add any additional code can be used, the disadvantage is that the charge, 64-bit version needs to buy licence, However, it is not very important to use 32-bit in 64 bits (unless your program requires a lot of computation).

  2. yet another Java Service Wrapper A version of the open source implementation similar to JSW, but official support is not very good.

  3. Apache Commons Daemon , a member of the famous Apache Commons Toolkit, adds the launcher according to the rules, and then writes the script implementation.

4. Other (such as winrun4j,launch4j) has not been used, more can refer to the Java Open Source packaging tools.

Note: focus on using Java Service wrapper to run Java programs as Windows services, it does not need to add any code, configuration can be.

Reference: http://blog.csdn.net/masson32/article/details/51802732

Java programs run as a service overview

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.