Linux Server Deployment jar packages and the writing of shell scripts

Source: Internet
Author: User

Background: Documenting the process of deploying a JAR program in a Linux environment

1 Deployment Process record 1.1 program structure

The main function here is in the Demrest2.java file.

For ease of deployment, do the following two points:

1 A dependent jar file is not included in the exported jar package

2 The configuration file used by the program allows the user to customize it without placing it in the jar package.

1.2 Exporting a JAR package

You can export the normal jar package here. To facilitate the transfer, only the necessary program files are exported.

After the jar package is exported, go to the exported jar package and delete the profile tws.properties file.

1.3 Program Deployment

Place all the required jar packages under the Lib directory, including the jar package for our export project Tws-client-demo.jar

In the user-defined directory, place the run script and configuration file.

PS: The directory where you run the script is the root directory where the program runs, and all the configuration files and running scripts are placed in the same directory.

Here in the program how to read the configuration file, but also need to study well ....

#!/bin/shsourcemsgpath=/home/tws/server/tws-test/usermsg/lxw//etc/profilefor i in $HOME /server/tws-test/lib/*;    Do CLASSPATH= $i:"$CLASSPATH"; doneexport CLASSPATH=.: ${classpath}java  demo.rest.DemRest2 $sourceMsgPath $1 "success!"  

Explain the above script:

To run the program:

Under the user directory, the program can read the configuration file outside the jar package.

2 Standard Scripts

An example of a script found on the Internet:

When writing a shell script error, it can be used as a reference:

/bin/shexport java_home=/usr/java/jdk1. 6 . 0_18export CLASSPATH=.:${java_home}/lib/dt.jar:${java_home}/lib/tools.jarfor i in Lib/*. Jar ;         Do CLASSPATH=$i: ${classpath} doneexport CLASSPATH=-CP ${classpath} The package name where the main method resides. The name of the class where the Main method resides
If the above script does not execute successfully, you can try
#!/bin//etc/profilesource ~/.bash_profile
Under test:
JAVA-CP Java's CP command JAVA-CP.; C:\dir1\lib.jar TEST-CP and-classpath, is the path of the specified class to run dependent on other classes, usually class libraries, jar packages, such as the full path to the jar package, window semicolon ";" Delimited, Linux is a semicolon ":" Delimited. Wildcard characters are not supported and all jar packages need to be listed with a little "." Represents the current path.

Linux Server Deployment jar packages and the writing of shell scripts

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.