Some common Java batch processing commands --

Source: Internet
Author: User
Tags apache tomcat
The following are some common batch processing commands in Java: 1. setlocal
Purpose: For commands in Windows NT, the changes to environment variables after this operation are only limited to those in the batch processing file. After the endlocal command is executed, the environment variables before setlocal are restored. When the batch file ends, an endlocal command is executed for each unfinished setlocal command by default. Common method: Add if "% OS %" = "windows_nt" setlocal to the batch processing header of the Set environment. After the batch processing is completed, the environment is restored to the environment before execution.
II.
Role: loop and batch processing play a powerful role. Java programs mainly use for to set classpath. Common method: directly execute for % I in (*. jar) Do call set classpath = % classpath %; % I add all the jar Suffixes in the current path to the classpath batch for % I in (*. jar) Do call set classpath = % classpath %; % I add all the jar Suffixes in the current path to classpath. In batch processing, variable definitions must begin with %. Note: I tried it in Window XP. If the classpath is empty before execution, the classpath will change to % classpath %; 1.jar; 2. jar. If you do not directly loop the set, execute for % I in (*. jar) Do call cpappend. bat % I (cpappend. set classpath = % classpath %; % 1) in BAT, and set the result to 1.jar; 2. jar .
Iii. Shift
Purpose: change the location of replaceable parameters in the batch file. If no parameter is added, replace the second parameter with the first parameter, and the third parameter with the second parameter, and so on. Common Methods: for example, cpappend. BAT in Apache Tomcat
If "% 1" "=" Goto end
Set classpath = % classpath %; % 1
Shift REM process the remaining arguments
: Setargs
If "% 1" "=" Goto donesetargs
Set classpath = % classpath % 1
Shift
Goto setargs
: Donesetargs
: End
You can replace parameters to use a fixed loop method to add parameters one by one to classpath (less useful)
Other batch processing commands, such as process control, are not listed one by one because they are the basis of batch processing. You can refer to the batch processing files of some open-source projects. The comments are quite rich. Just take a look at them and you will be able to understand them (BTW, remembering that I used Tomcat's cpappend six months ago. the bat file sets the class path and once wanted to understand its meaning. However, it was too impetuous to calm down. Today, half a year later, it looks pretty good for less than ten minutes, and it's just a sudden sensation. It's a bit of a sigh .)
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.