Tomcat running on Windows platform

 

  From the previous learning to know, you can call Bootstrap class Toomcat as a stand-alone application to run on the Windows platform, you can call startup.bat batch file to start Tomcat, or run the batch file to shut down Tomcat shutdown.bat these two batch files located in the% CATALINA_HOME% / bin directory, the following will be introduced to a batch script, if you are not familiar with the command to DOS, then you need to carefully read the following, how to write a batch file this paragraph ,

How to write a batch file

  The following will be introduced to the batch file, so you can understand used to start or shut down Tomcat batch file, will rem, if, echo, goto, lable commands are introduced, of course, does not cover the content of the presentation For even the content,

  First batch file extension must be .bat, after double-click a batch file from Windows Explorer, or you can type the name of the batch file in the DOS console to call it, call the batch file, each row command will be explained below will be on Tomcat batch file commands are introduced.

  Note: DOS commands and environment variables are case-sensitive,

  rem command: This command is used to annotate, the interpreter will not execute the command line to start the rem

  pause: pause command is used to pause a batch file is executed, and prompts the user to press a key, and the program will continue.

  echo: This command is used to display some files on the DOS console, for example, the following command will output Hello Word on the console, then pause the program, the reason for suspension of the program is to enable the console output text is displayed:  

echo Hello Word
pause

  If you want to display the values ​​of environment variables, you need to add% environment variable values ​​before and after, for example, the following command will output value of the variable myVar

echo %myVar%

  If you want to output the name of the operating system, you can use the following command

echo% OS%

  echo off(

 # The next line begins to close significant return

  Use echo off can prevent specific batch file command output, but only output the results, but the echo off command itself will still show up, if you want to echo off also hidden, need to use @echo off command.

  OFF @echo (  from the Bank began to close echo )

  This command echo off command is similar, but it will also chain echo off command to hide

  set 

  set command to set environment variables or user-defined name of an environment variable set in the batch file is temporarily stored in memory, after the completion of the batch file execution will be destroyed

  Example: The following command creates a set called THE_KING environment variable, its value is set to Elvis, and output to the console

set THE_KING=Elvis
echo %THE_KING%
pause

  label

  A tab is provided with a colon, then the label may be transferred to the goto command, so the program jumps to the label specified location, the following statement defines the end of a tab named

:end

There are more examples on the label, see the introduction to the goto command

  goto

  goto command to force the batch file jumps to the specified location where the label continues, examples are as follows:

echo Start
goto end
echo I Can guarantee this line will not be executed :end echo End pause

After the first line of the output of the Start, goto command executes the batch file jumps to the statement following the end tag continues, the result is to skip the third line, it is not executed

 if

   if the conditions for executing the test, there are the following three uses

  1. Value of the test variable
  2. Test whether a file exists
  3. Test error value

Use the following command format to test the value of a variable

if variable==value 

For example, if the value of the following statements will test variables myVar is not 3, and if so, it outputs Correct the console

set myVar=3
if  %myVar%==3 echo Correct

When running the above command, the value of the variable will be determined myVar, and outputs Correct

Can you use the following command format to test the file exists

if exist c:\temp\myFile.txt goto start

If c: presence myFile.txt file \ temp directory, the program will jump start position where the label continues, you can use the keywords not be negated to a statement

not

keyword is used for a statement not negated, for example, the following command Correct output value of the variable is not myVar 3

set myVar=3
if not %myVae%==3 echo Correct
pause

When the c: when \ myFile.txt file does not exist under the temp directory, the following command will jump to the location where the tag end to continue.

if not exist c:\temp\myFile.txt goto end

exist

  When test whether a file exists, will be used to exist if statements and commands, see the sample program if command examples

Receive parameters

  Parameters can be passed to the batch file, using 1% to refer to the first parameter,% 2 refers to the second parameter, and so on, for example: The following command will first console output parameter

  

1
echo % 1

  If the name of the batch file is test.bat, and use the test Hello command to call it, it will output in the console Hello

The following batch file will first parameter value to be checked, if the first argument is a start, it will output Starting application, if the first argument is stop, outputs Stopping application, otherwise the output Invalid parameter

Copy the code
echo off
if %1==start  goto start 
if %1==stop goto stop goto invalid :start echo Starting application goto end :stop echo Stopping application goto end :invalid echo Invalid parameter goto end :end
Copy the code

If the check run the batch file has a parameter may be 1% compared with the empty string, for example, the following batch file, if the runtime parameter is not used, the console will output No parameter

if "1%"=="" echo No parameter

or

if ""%1""=="""" echo No parameter

 shift 

command to shift to a rearward movement of all the parameters, the assigned value of 1% to 2%, 3% of the value assigned to 2%, and so on, for example, the following code uses a shift command

echo off
shift
echo %1
echo %2

When you are running the batch file if additional three parameters a, b, c, then the above will have the following command output

b

c

After the move, to use the 0% to refer to the first argument, and now the last parameter is ineffective.

call

call command used to invoke another command.

Another call to order a batch of the batch, otherwise the rest of the batch command will not be executed 
sometimes a call to start the application with an error, you can call call

setLocal

Use setLocal modify environment variables are valid only in the current batch script in a batch file, when faced with endLocal command, environment variables after setLocal settings revert to a previous state using SETLOCAL statement.

start

Open a new Windows console, and you can specify a name for the new console, for example:

start  "Title"

In addition, the command behind Titile, as well as a pass to be executed in the new console

For example: output this is new Title in the new Windows console

start "Title" echo this is New Title

Then the above generally describes some DOS batch file commands, we'll do to understand the priorities: Tomcat startup batch file

catalina.bat batch file

  catalina.bat batch file used to start or shut down Tomat, the other two files (startup.bat and shutdown.bat) provides a simpler method of startup and shut down Tomcat, in fact, startup.bat and will call shutdowm.bat catalian.bat and pass the appropriate parameters,

In the% CATALINA_HOME% / bin directory, you need to call catalina.bat script to the following syntax

catalina

Or use the following syntax to invoke the script from the% CATALINA_HOME% / bin directory

bin\catalina

Optional parameter command in both cases comprises:

  • Catalina debug start in the debugger
  • debug -security debugging Catalina in the case of the security manager
  • embedded in embedded mode starts Catalina
  • jpda start start in JPDA debugger Catalina
  • Catalina run start in the current window
  • run -security in the current window, start by Catalina Security Manager
  • Start Catalina start in a new window
  • start -security started by Catalina security manager in a new window
  • stop close Catalina

To start such as Catalina in a new window, you can use the following command

catalina start

  From the previous learning to know, you can call Bootstrap class Toomcat as a stand-alone application to run on the Windows platform, you can call startup.bat batch file to start Tomcat, or run the batch file to shut down Tomcat shutdown.bat these two batch files located in the% CATALINA_HOME% / bin directory, the following will be introduced to a batch script, if you are not familiar with the command to DOS, then you need to carefully read the following, how to write a batch file this paragraph ,

How to write a batch file

  The following will be introduced to the batch file, so you can understand used to start or shut down Tomcat batch file, will rem, if, echo, goto, lable commands are introduced, of course, does not cover the content of the presentation For even the content,

  First batch file extension must be .bat, after double-click a batch file from Windows Explorer, or you can type the name of the batch file in the DOS console to call it, call the batch file, each row command will be explained below will be on Tomcat batch file commands are introduced.

  Note: DOS commands and environment variables are case-sensitive,

  rem command: This command is used to annotate, the interpreter will not execute the command line to start the rem

  pause: pause command is used to pause a batch file is executed, and prompts the user to press a key, and the program will continue.

  echo: This command is used to display some files on the DOS console, for example, the following command will output Hello Word on the console, then pause the program, the reason for suspension of the program is to enable the console output text is displayed:  

echo Hello Word
pause

  If you want to display the values ​​of environment variables, you need to add% environment variable values ​​before and after, for example, the following command will output value of the variable myVar

echo %myVar%

  If you want to output the name of the operating system, you can use the following command

echo% OS%

  echo off(

 # The next line begins to close significant return

  Use echo off can prevent specific batch file command output, but only output the results, but the echo off command itself will still show up, if you want to echo off also hidden, need to use @echo off command.

  OFF @echo (  from the Bank began to close echo )

  This command echo off command is similar, but it will also chain echo off command to hide

  set 

  set command to set environment variables or user-defined name of an environment variable set in the batch file is temporarily stored in memory, after the completion of the batch file execution will be destroyed

  Example: The following command creates a set called THE_KING environment variable, its value is set to Elvis, and output to the console

set THE_KING=Elvis
echo %THE_KING%
pause

  label

  A tab is provided with a colon, then the label may be transferred to the goto command, so the program jumps to the label specified location, the following statement defines the end of a tab named

:end

There are more examples on the label, see the introduction to the goto command

  goto

  goto command to force the batch file jumps to the specified location where the label continues, examples are as follows:

echo Start
goto end
echo I Can guarantee this line will not be executed :end echo End pause

After the first line of the output of the Start, goto command executes the batch file jumps to the statement following the end tag continues, the result is to skip the third line, it is not executed

 if

   if the conditions for executing the test, there are the following three uses

  1. Value of the test variable
  2. Test whether a file exists
  3. Test error value

Use the following command format to test the value of a variable

if variable==value 

For example, if the value of the following statements will test variables myVar is not 3, and if so, it outputs Correct the console

set myVar=3
if  %myVar%==3 echo Correct

When running the above command, the value of the variable will be determined myVar, and outputs Correct

Can you use the following command format to test the file exists

if exist c:\temp\myFile.txt goto start

If c: presence myFile.txt file \ temp directory, the program will jump start position where the label continues, you can use the keywords not be negated to a statement

not

keyword is used for a statement not negated, for example, the following command Correct output value of the variable is not myVar 3

set myVar=3
if not %myVae%==3 echo Correct
pause

When the c: when \ myFile.txt file does not exist under the temp directory, the following command will jump to the location where the tag end to continue.

if not exist c:\temp\myFile.txt goto end

exist

  When test whether a file exists, will be used to exist if statements and commands, see the sample program if command examples

Receive parameters

  Parameters can be passed to the batch file, using 1% to refer to the first parameter,% 2 refers to the second parameter, and so on, for example: The following command will first console output parameter

  

1
echo % 1

  If the name of the batch file is test.bat, and use the test Hello command to call it, it will output in the console Hello

The following batch file will first parameter value to be checked, if the first argument is a start, it will output Starting application, if the first argument is stop, outputs Stopping application, otherwise the output Invalid parameter

Copy the code
echo off
if %1==start  goto start 
if %1==stop goto stop goto invalid :start echo Starting application goto end :stop echo Stopping application goto end :invalid echo Invalid parameter goto end :end
Copy the code

If the check run the batch file has a parameter may be 1% compared with the empty string, for example, the following batch file, if the runtime parameter is not used, the console will output No parameter

if "1%"=="" echo No parameter

or

if ""%1""=="""" echo No parameter

 shift 

command to shift to a rearward movement of all the parameters, the assigned value of 1% to 2%, 3% of the value assigned to 2%, and so on, for example, the following code uses a shift command

echo off
shift
echo %1
echo %2

When you are running the batch file if additional three parameters a, b, c, then the above will have the following command output

b

c

After the move, to use the 0% to refer to the first argument, and now the last parameter is ineffective.

call

call command used to invoke another command.

Another call to order a batch of the batch, otherwise the rest of the batch command will not be executed 
sometimes a call to start the application with an error, you can call call

setLocal

Use setLocal modify environment variables are valid only in the current batch script in a batch file, when faced with endLocal command, environment variables after setLocal settings revert to a previous state using SETLOCAL statement.

start

Open a new Windows console, and you can specify a name for the new console, for example:

start  "Title"

In addition, the command behind Titile, as well as a pass to be executed in the new console

For example: output this is new Title in the new Windows console

start "Title" echo this is New Title

Then the above generally describes some DOS batch file commands, we'll do to understand the priorities: Tomcat startup batch file

catalina.bat batch file

  catalina.bat batch file used to start or shut down Tomat, the other two files (startup.bat and shutdown.bat) provides a simpler method of startup and shut down Tomcat, in fact, startup.bat and will call shutdowm.bat catalian.bat and pass the appropriate parameters,

In the% CATALINA_HOME% / bin directory, you need to call catalina.bat script to the following syntax

catalina

Or use the following syntax to invoke the script from the% CATALINA_HOME% / bin directory

bin\catalina

Optional parameter command in both cases comprises:

  • Catalina debug start in the debugger
  • debug -security debugging Catalina in the case of the security manager
  • embedded in embedded mode starts Catalina
  • jpda start start in JPDA debugger Catalina
  • Catalina run start in the current window
  • run -security in the current window, start by Catalina Security Manager
  • Start Catalina start in a new window
  • start -security started by Catalina security manager in a new window
  • stop close Catalina

To start such as Catalina in a new window, you can use the following command

catalina start

Guess you like

Origin www.cnblogs.com/lcword/p/11785605.html