batch-filecmdjbossescapingwildfly

Proper way to set JAVA_OPTS that contains spaces in standalone.conf.bat in WildFly 8?


I'm having an issue consuming spaces when setting JAVA_OPTS in standalone.conf.bat in Wildfly8. Back in JBOSS 7 if I wanted to set a property that contained a space then I could do the following:

set "JAVA_OPTS=%JAVA_OPTS% -DDEV_HOME="C:\dev\TEST FOLDER""

From my understanding Windows would consume the outside quotes first and then treat the inner quotes as a single string. In Wildfly8 though I get the following error:

C:\dev\j2ee\wildfly-8.2.0.Final\bin>standalone.bat
Calling "C:\dev\j2ee\wildfly-8.2.0.Final\bin\standalone.conf.bat"
FOLDER"  | findstr /r /c:"-Djboss.server.base.dir" > nul && (
FOLDER"  | findstr /r /c:"-Djboss.server.config.dir" > nul && (
FOLDER"  | findstr /r /c:"-Djboss.server.log.dir" > nul && (
else was unexpected at this time.`

The same property gets interpreted properly if it contains no space. It seems like the space is interpreted as a delimiter despite quotes. I'm not sure what the proper way to set a property that contains a space would be. I've tried escaping with \ with ^ and using "" all to similar effect.


Solution

  • You could use the old filename conventions in "8.3 format" instead of the real filename. So "C:\Program Files" is converted to "C:\PROGRA~1". That way there's no problem with spaces. The "dir /x" command will show the filenames in the old way.