Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install Tomcat 7 as a Windows service using command line install

I need to install Tomcat 7 as a Windows service and to start the service manually.

Referring to How to install Tomcat as a Windows service, I believe I would need to specify the following on the command line:

tomcat7 //IS//Tomcat7 --DisplayName="Apache Tomcat 7" --Install="C:\Tomcat7\bin\tomcat7.exe

Do I also need to specify all or some of the following on the command line like in the example? If only some, please specify which ones. If anything in the example is incorrect, please specify.

--Jvm=auto
--StartMode=jvm
--StopMode=jvm 
--StartClass=org.apache.catalina.startup.Bootstrap
--StartParams=start
--StopClass=org.apache.catalina.startup.Bootstrap 
--StopParams=stop

What I need for sure is to specify the following because I need to tell Tomcat to use a specific java home and not the java home set by the environment variable JAVA_HOME on the server where this will be installed.

--JavaHome="C:\Program Files\Java\jdk1.7.0_51

The reason: the server already has a different version of Tomcat (5.5) and it uses an older version of the JDK (1.5). I must not change JAVA_HOME on the server. I simply need to ensure Tomcat 7 uses JDK 1.7 and I have tried this line:

C:\tomcat7\bin>tomcat7 //IS//Tomcat7 --DisplayName="Apache Tomcat 7" --Install="C:\Tomcat7\bin\tomcat7.exe" --JavaHome="C:\Program Files\Java\jdk1.7.0_51"

When I attempt to Start the service, the following error message is displayed:

Windows could not start the Apache Tomcat 7 on Local Computer. For
more information, review the System Event Log. If this is a
non-Microsoft service, contact the service vendor, and refer to
service-specific error code 1.

I had a look at the System Event Viewer and it provides the following information:

The Apache Tomcat 7 service terminated with service-specific error Incorrect function..

I need to figure out these steps because I then need to provide the support team with the information to install this service on the production server. So any help would be greatly appreciated!

like image 681
javagirl Avatar asked Nov 10 '22 12:11

javagirl


1 Answers

Use Chocolatey from Powershell command line:

first install Chocolatey

PS:\> iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))

To install Tomcat

PS:\> choco install tomcat

To upgrade

PS:\> choco upgrade tomcat
like image 93
Vic Avatar answered Nov 15 '22 06:11

Vic