Bug 66829 - setclasspath.bat: troubles when _RUNJAVA contains spaces
Summary: setclasspath.bat: troubles when _RUNJAVA contains spaces
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 11
Classification: Unclassified
Component: Catalina (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal (vote)
Target Milestone: -------
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-01 14:21 UTC by Дилян Палаузов
Modified: 2023-08-03 18:37 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Дилян Палаузов 2023-08-01 14:21:53 UTC
Catalina.bat permits me to set the environment variable _RUNJAVA before calling «catalina.bat start».  If the variable value contains space, e.g. is from WSL

export _RUNJAVA=\"C:\\Program\ Files\ \(x86\)\\Java\\jdk1.8.0_361\\bin\\java.exe\"; export WSL=_RUNJAVA ; cmd.exe /c 'catalina.bat start'

then the output it

Files was unexpected at this time.

“Files“ is from “Program Files”.  In I replace in setclasspath.bat 

> if not "%_RUNJAVA%" == "" goto gotRunJava

with

> if not defined %_RUNJAVA% goto gotRunJava

then the problem disappears.

Yes, Java 8 does not run with Tomcat 11. But this problem actually appears with Tomcat 9 and setclasspath.bat has not changed between Tomcat 9 and Tomcat 10.1.

• In bin/setclasspath.bat replace «if not "%_RUNJAVA%" == "" goto gotRunJava» with «if not defined %_RUNJAVA% goto gotRunJava».
Comment 1 Mark Thomas 2023-08-03 14:41:29 UTC
For those trying to recreate this, WSL appears to be a red herring. Simply creating a _RUNJAVA variable containing a space is sufficient to break things.
Comment 2 Дилян Палаузов 2023-08-03 15:19:41 UTC
The same problem is described at https://bz.apache.org/bugzilla/show_bug.cgi?id=66056 

In the bug report I wrote as substutution

> if not defined %_RUNJAVA% goto gotRunJava

but it should be

> if defined _RUNJAVA goto gotRunJava
Comment 3 Mark Thomas 2023-08-03 15:45:32 UTC
I think there may be some issues with spaces in the path to Java but the example in the original report is wrong. It uses

set VAR="value with spaces"

it should be

set "VAR=value with spaces"

I'm continuing to investigate spaces in JAVA_HOME and _RUNJAVA
Comment 4 Mark Thomas 2023-08-03 18:37:28 UTC
The issue was just with _RUNJAVA and _RUNJDB

Fixed in:
- 11.0.x for 11.0.0-10 onwards
- 10.1.x for 10.1.12 onwards
-  9.0.x for  9.0.79 onwards
-  8.5.x for  8.5.92 onwards