Packaged Java applications as services under Linux __linux

Source: Internet
Author: User
packaging Java applications into services under Linux1

This article describes how to use the Java Wrapper service in the following steps: (Tested through CentOS5.1 Linux)


1. From http://wrapper.tanukisoftware.org/doc/english/download.jsp

Download Wrapper-linux-x86-32-3.3.1.tar (please use the Community version, because professional and standard version need to purchase licenses);

2. Decompression Wrapper-linux-x86-32-3.3.1.tar for wrapper-linux-x86-32-3.3.1;

3. Prepare the directory for the Program (APP), including Bin,conf,lib,logs:

4. Copy wrapper-linux-x86-32-3.3.1\bin\wrapper (for binary file) to bin\;

5. Copy wrapper-linux-x86-32-3.3.1\src\bin\sh.script.in to bin\ and renamed app to copy the configuration files used by the app to the directory, including. Ini,.xml;

6. Copy wrapper-linux-x86-32-3.3.1\src\conf\wrapper.conf.in to conf\, and renamed to Wrapper.conf;

7. Copy wrapper-linux-x86-32-3.3.1\lib\wrapper.jar,libwrapper.so to lib\ and copy the jar package used by app to the directory;

8. Edit the app, set the name of the application (use NotePad2 or EditPlus when you edit)

# application
App_name= "MailSender"
App_long_name= "MailSender Application"

9. Editor Wrapper.conf

#********************************************************************
# wrapper Java Properties
#********************************************************************
# Java Application
Wrapper.java.command=/usr/java/jdk1.5.0/bin/java

# Java Main class. This class must implement the Wrapperlistener interface
# or guarantee that's Wrappermanager class is initialized. Helper
# classes are provided to doing this for you. The integration section
# of the documentation for details.
Wrapper.java.mainclass=org.tanukisoftware.wrapper.wrappersimpleapp #默认使用

# Java Classpath (include Wrapper.jar) Add class path elements as
# needed starting from 1

Wrapper.java.classpath.1=.. /lib/wrapper.jar
Wrapper.java.classpath.2=.. /lib/classes12.jar #其它引入jar
Wrapper.java.classpath.3=.. /lib/activation.jar #其它引入jar
Wrapper.java.classpath.4=.. /lib/mail.jar #其它引入jar
Wrapper.java.classpath.5=.. /lib/app.jar #当前应用jar

# Java Library Path (location of Wrapper.DLL or libwrapper.so)
Wrapper.java.library.path.1=.. /lib #Windows version uses the Wrapper.dll,linux version libwrapper.so

# application parameters. ADD parameters as needed starting from 1
Wrapper.app.parameter.1=com.wisdom.mail.main #app应用启动类

#********************************************************************
# wrapper Windows Properties
#********************************************************************
# Title to use when running as a console
Wrapper.console.title=appname Application

10. Use SSH to upload the app directory to the Linux server/usr/local/app;

11. Login SSH, execute:

#chmod 755/usr/local/app

#cd/usr/local/app/bin

#sudo chmod 755 App

#sudo chmod 755 Wrapper

Complete deployment;

The last command resolves: unable to locate any of the following binaries:
/app/bin/./wrapper-linux-x86-32
/app/bin/./wrapper-linux-x86-64
/app/./wrapper (Found but not executable.) problem;

12. Execute command:/usr/local/app/bin/app Console|start|stop|restart can start the service.

If you want to check that the service is performing properly, you can use the console parameter first, and start the service if you are normal.



Usage:/usr/local/tserverproxy/bin/app [Console | start | stop | restart | condrestart | status | install | remove | dump ]


Commands:
Console Launch in the current console.
Start start in the background as a daemon process.
Stop stop if running as a daemon or in another console.
Restart Stop if running and then start.
Condrestart Restart only if already running.
Status Query the current status.
Install install to start automatically when system boots.
Remove Uninstall.
Dump Request a Java thread dump if running.




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.