When attempting to install Tomcat as a Windows service, bin/service.bat checks for the existence of java.exe and javaw.exe in the JRE's bin directory and fails if either does not exist. java.exe exists on all of the Java distributions for Windows, but javaw.exe exists only on distributions that utilize GUI. The Server JRE, which is the recommended distribution for server deployments does not include javaw.exe, and therefore the service installation from service.bat fails. I checked with both Java 1.8u171 and Java 10.0.1: $ ls -al server-jre\jdk1.8.0_171\bin\ | grep java -rwxr-xr-x 1 Admin None 16808 Mar 28 17:15 java-rmi.exe -rwxr-xr-x 1 Admin None 207784 Mar 28 17:15 java.exe -rwxr-xr-x 1 Admin None 16808 Mar 28 17:15 javac.exe $ ls -al server-jre\jdk-10.0.1\bin\ | grep java -rwxr-xr-x 1 Admin None 150448 Mar 26 19:02 java.dll -rwxr-xr-x 1 Admin None 232368 Mar 26 19:02 java.exe -rwxr-xr-x 1 Admin None 17840 Mar 26 19:02 javac.exe -rwxr-xr-x 1 Admin None 166320 Mar 26 19:02 javajpeg.dll The fix is very easy. The line if not exist "%JRE_HOME%\bin\javaw.exe" goto noJavaHome at https://github.com/apache/tomcat/blob/trunk/bin/service.bat#L55 should be removed.
The proposed change makes sense to me. A couple of questions come to mind: 1. Why was the script written to check for both files? Is there any explanation in the svn history? 2. Does the Windows installer have a similar problem?
IIRC, java.exe will always open a command-prompt to run the command. That's why javaw.exe exists. For a "server install", does that mean that a console needs to be available because java.exe will run instead of javaw.exe? Windows Service probably works regardless.
Take a look at the svn history. As far as I can tell, javaw.exe has never been used.
> IIRC, java.exe will always open a command-prompt to run the command. That's why javaw.exe exists. Right, but that is for Windowed, GUI applications where you don't want a console window to open with the application. I believe that that's where the `w` comes from in `javaw`. > Take a look at the svn history. As far as I can tell, javaw.exe has never been used. I have been using Tomcat with the Server JRE on Windows for a few years now. The Windows service runs well with the `java.exe` only. The only problem is with the installation of the Windows Service via `service.bat`. If there is no objection then I will go ahead and remove the offensive line.
(In reply to Mark Thomas from comment #1) > <snip/> > 2. Does the Windows installer have a similar problem? I just ran the Windows Service Installer executable of Tomcat 9.0.8 on Windows 10 and pointed it to the Server JRE which does not have the `javaw.exe` file. The installation completed with no errors and the service started successfully, so this issue does not affect the Windows Service Installer.
Fixed in: - trunk for 9.0.9 onwards - 8.5.x for 8.5.32 onwards - 8.0.x for 8.0.53 onwards - 7.0.x for 7.0.89 onwards I removed all references to javaw.exe from the scripts. I also checked for references anywhere else in the source code. There were none.