Installing services

The safest way to manually install the service is to use the provided service.bat script. Administrator privileges are required to run this script. If necessary, you can use the /user switch to specify a user to use for the installation of the service.

NOTE: On Windows Vista or any other operating system with User Account Control (UAC) you must either disable UAC or right-click on cmd.exe and select "Run as administrator" in order to run this script. If UAC is enabled neither being logged on with an Administrator account, nor using the /user switch is sufficient.

Install the service named 'Tomcat7'
C:\> service.bat install

If using tomcat7.exe, you need to use the //IS// parameter.

Install the service named 'Tomcat7'
C:\> tomcat7 //IS//Tomcat7 --DisplayName="Apache Tomcat 7" \
C:\> --Install="C:\Program Files\Tomcat\bin\tomcat7.exe" --Jvm=auto \
C:\> --StartMode=jvm --StopMode=jvm \
C:\> --StartClass=org.apache.catalina.startup.Bootstrap --StartParams=start \
C:\> --StopClass=org.apache.catalina.startup.Bootstrap --StopParams=stop

Updating services

To update the service parameters, you need to use the //US// parameter.

Update the service named 'Tomcat7'
C:\> tomcat7 //US//Tomcat7 --Description="Apache Tomcat Server - http://tomcat.apache.org/ " \
C:\> --Startup=auto --Classpath=%JAVA_HOME%\lib\tools.jar;%CATALINA_HOME%\bin\bootstrap.jar

Removing services

To remove the service, you need to use the //DS// parameter.
If the service is running it will be stopped and then deleted.

Remove the service named 'Tomcat7'
C:\> tomcat7 //DS//Tomcat7

Debugging services

To run the service in console mode, you need to use the //TS// parameter. The service shutdown can be initiated by pressing CTRL+C or CTRL+BREAK. If you rename the tomcat7.exe to testservice.exe then you can just execute the testservice.exe and this command mode will be executed by default.

Run the service named 'Tomcat7' in console mode
C:\> tomcat7 //TS//Tomcat7 [additional arguments]
Or simply execute:
C:\> tomcat7

参考:http://tomcat.apache.org/tomcat-7.0-doc/windows-service-howto.html

posted @ 2011-10-09 14:18 无尽思绪 阅读(30) 评论(0) 编辑

Configure JDK

Set the JAVA_HOME environment variable to the root location of the JDK installation directory. The examples below use C:\jdk1.5 for Windows and/opt/jdk1.5 for UNIX, but be sure to use the actual location on your system. (e.g. The default installation location used by the JDK installer might be something like C:\Program Files\Java\jdk1.5.0_06)

Windows: C:\> set JAVA_HOME=C:\jdk1.5

UNIX Korn Shell: $ export JAVA_HOME=/opt/jdk1.5

Next set the PATH environment variable to include the JDK bin directory. The PATH variable tells the operating system where to find the java interpreter and the javac compiler.

Windows: C:\> set PATH=%PATH%;%JAVA_HOME%\bin

In Windows, these envoronment variables can also be set from - right click "My Computer" -> Advanced -> Environment Variables.

UNIX Korn Shell: $ export PATH=$JAVA_HOME/bin:$PATH

Verify JDK

Use the java -version command, as shown below, to verify the installed release:

java -version java version "1.5.0_06" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05) Java HotSpot(TM) Client VM (build 1.5.0_06-b05, mixed mode, sharing)

The output you see may be different from what is shown above because the java -version command outputs vendor-specific information; however, if you don't see what looks like valid version information, then STOP! And don't proceed until you resolve that problem.

reference: http://db.apache.org/derby/papers/DerbyTut/install_software.html#jdk_configure

posted @ 2011-10-09 14:08 无尽思绪 阅读(14) 评论(0) 编辑