You need to surround the value of the JAVA_HOME variable with double quotes because it contains spaces
The JAVA_HOME
variable that contains the path to the root-directory of your java environment contains spaces: C:\Program Files (x86)\Java
. It is used at the 3rd last line:
%JAVA_HOME%\bin\java -classpath...
So by just substituting the value of %JAVA_HOME%
you get:
C:\Program Files (x86)\bin\java -classpath...
You would say: "it's just a path to the java executable". But that's not how the command interpreter sees it, it will think you are giving 3 different things: C:\Program
Files
(x86)
(it just takes the whitespace as separator for arguments as usual!). It then will take the first one C:\Program
as the path to an executable program and the rest of the line as its arguments. Because C:\Program
is not the path to a valid executable you get the error
'C:\Program' is not recognized as an external or internal command`
So to let it know he always has to see the C:\Program Files (x86)
as a whole (part of a same thing: one path to a directory) you just surround it with double quotes. In batch it is always wise to surround variables with double quotes when they represent a path! Now you have 3 options:
The most easy one (will only solve this specific problem): replace
set JAVA_HOME=C:\Program Files (x86)\Java
with
set JAVA_HOME="C:\Program Files (x86)\Java"
This way you make sure everywhere JAVA_HOME is used, you will get no more problems because of the spaces arround "Files"
Go everywhere you used %JAVA_HOME%
and replace it with "%JAVA_HOME%"
(just surround with double quotes). You can do the same for all usages of %JFLEX_HOME%
as this also represents a path
The last option (the most general, one you should consider as a rule in batch) surround all representations of paths (literal paths or paths set in variables) with double quotes.