1

Does anyone know how to install Apache Tomcat 10 silently on the commandline?

I have tried /S and it just doesn't work. It seems like nothing is running and I get no error, it just goes directly to another command prompt.

Without any arguments the installer comes up properly.

I want everything installed as default except for the windows service to be set to auto instead of manual.

Piotr P. Karwasz
  • 12,857
  • 3
  • 20
  • 43
Tacitus86
  • 1,314
  • 2
  • 14
  • 36

1 Answers1

1

Installation using the Windows installer

Tomcat's Windows installer is an NSIS installer, therefore it supports the standard /S command switch.

All other standard NSIS options also work, so if your want to install it in another folder, just execute in a cmd prompt:

tomcat-<version>.exe /S /D=D:\installation path\with spaces

The only non standard command line options are:

  • /? which prints a nice usage message,
  • /C=config.ini, which allows to set other variables in an *.ini file. The complete list of variables you can set can be found in the source script.

Installation from zip archive

Tomcat installation sums up to:

  • unpacking the files in a directory,
  • installing the service.

Therefore you can download the "64-bit Windows zip" and unpack it.

The Tomcat10.exe executable in the bin folder is the executable used to install the service and it is actually a copy of prunsrv. You can find the list of command line parameters in its documentation.

Instead of calling directly prunsrv, it is easier to use the service.bat script in the same folder:

set "SERVICE_STARTUP_MODE=auto"
service.bat install

There is no "silent" switch, but all the output is done by the script itself, so you can comment it out.

Edit: Although the service.bat script has only a couple of arguments available:

service.bat install/remove [service_name [--rename]] [--user username]

some parameters can be provided through environment variables:

  • the standard CATALINA_HOME, CATALINA_BASE, JAVA_HOME and JRE_HOME,
  • the obsolete JAVA_ENDORSED_DIRS to set the java.endorsed.dirs system property,
  • SERVICE_STARTUP_MODE to choose the service's startup mode between manual (default), delayed or auto,
  • JvmMs to set the initial memory pool size in MiB (default 128),
  • JvmMx to set the maximum memory pool size in MiB (default 256).
Piotr P. Karwasz
  • 12,857
  • 3
  • 20
  • 43
  • Where do I get this service.bat file? – Tacitus86 May 12 '21 at 00:58
  • And does this also install tomcat application in addition to the service? – Tacitus86 May 12 '21 at 00:59
  • Sorry, I thought you were using the zip distribution instead of the Windows installer. I modified the answer accordingly. – Piotr P. Karwasz May 12 '21 at 04:46
  • Okay I grabbed the zip version and now I understand that the contents can just be dropped anywhere and one just needs to install the service to activate it via this service.bat file, but I still don't know WHERE to get the service.bat as it is not in the .zip. – Tacitus86 May 12 '21 at 13:01
  • Did you download the _"64-bit Windows zip"_ org _"32-bit Windows zip"_ from the [download page](https://tomcat.apache.org/download-10.cgi)? – Piotr P. Karwasz May 12 '21 at 13:31
  • I grabbed the first item there listed as "zip". – Tacitus86 May 12 '21 at 13:53
  • I finally got this to kind of work but when I try to start the service, Tomcat immediately stops with nothing in the log files. Are there any Env Variables that I need to manually set up when installing via this method? – Tacitus86 May 13 '21 at 18:53
  • All I've done so far was place the contents of the zip file on my drive where I want tomcat installed (C:\Program Files (x86)\Apache Software Foundation\apache-tomcat-10.0.5) and used the service.bat install command to set up the service. I tried to add JAVA_HOME and CATALINA_HOME env variables but the thing still refuses to start. Did I miss something? – Tacitus86 May 13 '21 at 18:59
  • Check whether Java and Tomcat10.exe have the same architecture (both 32 or 64 bits): in an administrator `cmd` run `java -version` and `Tomcat10.exe //VS`. – Piotr P. Karwasz May 13 '21 at 19:12
  • Java 1.8.0_151 it's 32 bit. Tomcat says version 1.2.4.0/Win32 Just to let you know if I run the startup.bat the command window, I can see some logs and something die after a split second (in a second command window that it opens) but for some reason this never makes it to the log file. It happens too quickly for me to see it. – Tacitus86 May 13 '21 at 19:33
  • I got it. The base dir didn't exist because I had a bad path. But this SHOULD have shown in the log. Not sure why it didn't. – Tacitus86 May 13 '21 at 19:40
  • So I got this to run but it seems like it doesn't set the ${catalina.home} path right. I noticed it's because I have spaces in my paths for jre_home and catalina_home env variables. It seem to not properly handle the spaces. Any idea how I can get it to work? I can tell because no logs are being written to the CATALINA_HOME/logs folder. – Tacitus86 May 21 '21 at 04:34
  • 1
    You can look at the registry keys under `HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Apache Software Foundation\Procrun 2.0` to check if spaces got messed up. If you used `set "CATALINA_HOME=..."` try `set CATALINA_HOME="..."`. – Piotr P. Karwasz May 21 '21 at 04:53
  • They all look fine in there. I'm judging by the fact that I can't get to any of my pages off of localhost (where I have defined in Tomcat/conf/Catalina/localhost/page.xml) and the logs aren't being written. Both use ${catalina.home}. But I see -DCatalina.home set in the registry keys. That's why I assumed it was an env variable issue. Any other ideas? – Tacitus86 May 21 '21 at 13:57
  • 1
    I added a comment [on your new question](https://stackoverflow.com/q/67629071/11748454). I tested a `CATALINA_BASE` with spaces and except a permission problem everything worked out. – Piotr P. Karwasz May 21 '21 at 14:07
  • You were spot on. It was the permissions not the env variables. Thanks Piotr! You are the man! – Tacitus86 May 21 '21 at 14:41