The sh script sharing _java of Java program under Linux

Source: Internet
Author: User

Today, it's going to take a day to study how to execute a Java program with a script, and finally realize, share

(1) Write an. sh file under Linux

(2) The contents of the document are as follows:

Copy Code code as follows:

#!/bin/sh//bash File Header
APP_HOME=/HOME/BLMCRM/CRM/A//The previous directory of the bin file in the Java file to execute, my directory is/HOME/BLMCRM/CRM/A/BIN/BLM ... (Do not write later), in short, is to write the bin directory in front of the section, because the jar package in the bin directory, if not in the bin, also so change the line
classpath= $APP _home/bin//bin Directory is of course a directory containing JAR packages.
For i in "$APP _home"/bin/*.jar//All jar packs are introduced here, the loops used here, of course, can also be written in this format one by one
Todo
Classpath= "$CLASSPATH": "$i"//environment variable in this format
Done
Export classpath=.: $CLASSPATH//Don't write this may say the main class is not found
echo ${classpath}//Print environment variable, can not write
java-xms50m-xmx250m Org.gdh.blm.exec.Syslog_csv
Exit (end)//execute Java program, where-xms50m-xmx250m is the setting for running memory, followed by the bin directory until the. class path, mine is Syslog_csv.class, so my last one is syslog_csv.

Do not know how to write detailed, everyone is not the same, for reference only, but the setting of the environment variable is the most important, I was the environment variable has been wrong, always according to the internet to find out, do not understand how, just have been wrong, in fact, the environment variable is the Java program you want to execute location, right,. The execution of SH is in the terminal input SH aa.sh

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.