Bug 62107 - jmeter.bat fails to execute due to space in the (program files) for jdk path
Summary: jmeter.bat fails to execute due to space in the (program files) for jdk path
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: Main (show other bugs)
Version: 3.2
Hardware: PC All
: P2 normal (vote)
Target Milestone: JMETER_5.0
Assignee: JMeter issues mailing list
URL:
Keywords: FixedInTrunk
: 62106 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-02-15 14:56 UTC by Manu
Modified: 2018-09-07 15:39 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Manu 2018-02-15 14:56:27 UTC
It looks like jmeter.bat breaks with "C:\Program Files......." due to the space. JDK 1.8 64bit.

Debug: CURRENT=8 - MINIMAL=8

c:\apache-jmeter-3.2\bin>if 8 LSS 8 (

 set ERRORLEVEL=3
 goto pause
)
Files\Java\jdk1.8.0_162\bin\ was unexpected at this time.
c:\apache-jmeter-3.2\bin>if .C:\Program Files\Java\jdk1.8.0_162\bin\ == . set JM_LAUNCH=java.exe
c:\apache-jmeter-3.2\bin>
Comment 1 Felix Schumacher 2018-02-15 18:56:00 UTC
*** Bug 62106 has been marked as a duplicate of this bug. ***
Comment 2 Felix Schumacher 2018-02-15 19:27:09 UTC
Thanks for the report. This has been fixed in trunk.

Would you be able to verify, that it solves your problem?

Date: Thu Feb 15 19:25:26 2018
New Revision: 1824348

URL: http://svn.apache.org/viewvc?rev=1824348&view=rev
Log:
JMeter fails to start under Windows when JM_LAUNCH contains spaces

Bugzilla Id: 62107

Modified:
    jmeter/trunk/bin/jmeter.bat
    jmeter/trunk/xdocs/changes.xml
Comment 3 Manu 2018-02-16 03:40:41 UTC
I took the jmeter.bat from the corresponding svn location and tried. It results in below error.
"'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
errorlevel=9009
Press any key to continue . . ."
Comment 4 Manu 2018-02-16 04:32:20 UTC
c:\apache-jmeter-3.2\bin>jmeter.bat

c:\apache-jmeter-3.2\bin>rem   Licensed to the Apache Software Foundation (ASF) under one or more

c:\apache-jmeter-3.2\bin>rem   contributor license agreements.  See the NOTICE file distributed with

c:\apache-jmeter-3.2\bin>rem   this work for additional information regarding copyright ownership.

c:\apache-jmeter-3.2\bin>rem   The ASF licenses this file to You under the Apache License, Version 2.0

c:\apache-jmeter-3.2\bin>rem   (the "License"); you may not use this file except in compliance with

c:\apache-jmeter-3.2\bin>rem   the License.  You may obtain a copy of the License at

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem       http://www.apache.org/licenses/LICENSE-2.0

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   Unless required by applicable law or agreed to in writing, software

c:\apache-jmeter-3.2\bin>rem   distributed under the License is distributed on an "AS IS" BASIS,

c:\apache-jmeter-3.2\bin>rem   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

c:\apache-jmeter-3.2\bin>rem   See the License for the specific language governing permissions and

c:\apache-jmeter-3.2\bin>rem   limitations under the License.

c:\apache-jmeter-3.2\bin>rem   =====================================================

c:\apache-jmeter-3.2\bin>rem   Environment variables that can be defined externally:

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   Do not set the variables in this script. Instead put them into a script

c:\apache-jmeter-3.2\bin>rem   setenv.bat in JMETER_HOME/bin to keep your customizations separate.

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   DDRAW       - (Optional) JVM options to influence usage of direct draw,

c:\apache-jmeter-3.2\bin>rem                 e.g. '-Dsun.java2d.ddscale=true'

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   JMETER_BIN  - JMeter bin directory (must end in \)

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   JMETER_COMPLETE_ARGS - if set indicates that JVM_ARGS is to be used exclusively instead

c:\apache-jmeter-3.2\bin>rem                 of adding other options like HEAP or GC_ALGO

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   JMETER_HOME - installation directory. Will be guessed from location of jmeter.bat

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   JM_LAUNCH   - java.exe (default) or javaw.exe

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   JM_START    - set this to "start" to launch JMeter in a separate window

c:\apache-jmeter-3.2\bin>rem                 this is used by the jmeterw.cmd script.

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   JVM_ARGS    - (Optional) Java options used when starting JMeter, e.g. -Dprop=val

c:\apache-jmeter-3.2\bin>rem                 Defaults to '-Duser.language="en" -Duser.region="EN"'

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   GC_ALGO     - (Optional) JVM garbage collector options

c:\apache-jmeter-3.2\bin>rem                 Defaults to '-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20'

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   HEAP        - (Optional) JVM memory settings used when starting JMeter

c:\apache-jmeter-3.2\bin>rem                 Defaults to '-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m'

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   =====================================================

c:\apache-jmeter-3.2\bin>setlocal

c:\apache-jmeter-3.2\bin>rem Guess JMETER_HOME if not defined

c:\apache-jmeter-3.2\bin>set "CURRENT_DIR=c:\apache-jmeter-3.2\bin"

c:\apache-jmeter-3.2\bin>if not "" == "" goto gotHome

c:\apache-jmeter-3.2\bin>set "JMETER_HOME=c:\apache-jmeter-3.2\bin"

c:\apache-jmeter-3.2\bin>if exist "c:\apache-jmeter-3.2\bin\bin\jmeter.bat" goto okHome

c:\apache-jmeter-3.2\bin>cd ..

c:\apache-jmeter-3.2>set "JMETER_HOME=c:\apache-jmeter-3.2"

c:\apache-jmeter-3.2>cd "c:\apache-jmeter-3.2\bin"

c:\apache-jmeter-3.2\bin>if exist "c:\apache-jmeter-3.2\bin\jmeter.bat" goto okHome

c:\apache-jmeter-3.2\bin>rem Get standard environment variables

c:\apache-jmeter-3.2\bin>if exist "c:\apache-jmeter-3.2\bin\setenv.bat" call "c:\apache-jmeter-3.2\bin\setenv.bat"

c:\apache-jmeter-3.2\bin>if not defined JMETER_LANGUAGE (
rem Set language
 rem Default to en_EN
 set JMETER_LANGUAGE=-Duser.language="en" -Duser.region="EN"
)

c:\apache-jmeter-3.2\bin>rem Minimal version to run JMeter

c:\apache-jmeter-3.2\bin>set MINIMAL_VERSION=1.8.0

c:\apache-jmeter-3.2\bin>rem --add-modules java.activation if JAVA 9

c:\apache-jmeter-3.2\bin>set JAVA9_OPTS=

c:\apache-jmeter-3.2\bin>for /F "tokens=3" %g in ('java -version 2>&1 | findstr /i "version"') do (
rem @echo Debug Output: %g
 set JAVAVER=%g
)

c:\apache-jmeter-3.2\bin>(
rem @echo Debug Output: "1.8.0_162"
 set JAVAVER="1.8.0_162"
)

c:\apache-jmeter-3.2\bin>if not defined JAVAVER (

 set ERRORLEVEL=2
 goto pause
)

c:\apache-jmeter-3.2\bin>rem Check if version is from OpenJDK or Oracle Hotspot JVM prior to 9 containing 1.${version}.x

c:\apache-jmeter-3.2\bin>rem JAVAVER will be equal to "9.0.4" (quotes are part of the value) for Oracle Java 9

c:\apache-jmeter-3.2\bin>rem JAVAVER will be equal to "1.8.0_161" (quotes are part of the value) for Oracle Java 8

c:\apache-jmeter-3.2\bin>rem so we extract 2 chars starting from index 1

c:\apache-jmeter-3.2\bin>IF "1." == "1." (
set JAVAVER=1.8.0_162
 for /F "delims=. tokens=1-3" %v in (""1.8.0_162"") do (set current_minor=%w )
)  else (
rem Java 9 at least
 set current_minor=9
 set JAVA9_OPTS=--add-modules java.activation --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED
)

c:\apache-jmeter-3.2\bin>(set current_minor=8 )

c:\apache-jmeter-3.2\bin>for /F "delims=. tokens=1-3" %v in ("1.8.0") do (set minimal_minor=%w )

c:\apache-jmeter-3.2\bin>(set minimal_minor=8 )

c:\apache-jmeter-3.2\bin>if not defined current_minor (

 set ERRORLEVEL=2
 goto pause
)

c:\apache-jmeter-3.2\bin>rem @echo Debug: CURRENT=8 - MINIMAL=8

c:\apache-jmeter-3.2\bin>if 8 LSS 8 (

 set ERRORLEVEL=3
 goto pause
)

c:\apache-jmeter-3.2\bin>if not defined JM_LAUNCH (set JM_LAUNCH=java.exe )

c:\apache-jmeter-3.2\bin>if exist jmeter.bat goto winNT1

c:\apache-jmeter-3.2\bin>rem On NT/2K grab all arguments at once

c:\apache-jmeter-3.2\bin>set JMETER_CMD_LINE_ARGS=

c:\apache-jmeter-3.2\bin>rem The following link describes the -XX options:

c:\apache-jmeter-3.2\bin>rem http://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html

c:\apache-jmeter-3.2\bin>if not defined HEAP (
rem See the unix startup file for the rationale of the following parameters,
 rem including some tuning recommendations
 set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m
)

c:\apache-jmeter-3.2\bin>rem Uncomment this to generate GC verbose file with Java prior to 9

c:\apache-jmeter-3.2\bin>rem set VERBOSE_GC=-verbose:gc -Xloggc:gc_jmeter_%p.log -XX:+PrintGCDetails -XX:+PrintGCCause -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintAdaptiveSizePolicy

c:\apache-jmeter-3.2\bin>rem Uncomment this to generate GC verbose file with Java 9 and above

c:\apache-jmeter-3.2\bin>rem set VERBOSE_GC=-Xlog:gc*,gc+age=trace,gc+heap=debug:file=gc_jmeter_%p.log

c:\apache-jmeter-3.2\bin>rem You may want to add those settings

c:\apache-jmeter-3.2\bin>rem -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem

c:\apache-jmeter-3.2\bin>if not defined GC_ALGO (set GC_ALGO=-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 )

c:\apache-jmeter-3.2\bin>set SYSTEM_PROPS=-Djava.security.egd=file:/dev/urandom

c:\apache-jmeter-3.2\bin>rem Always dump on OOM (does not cost anything unless triggered)

c:\apache-jmeter-3.2\bin>set DUMP=-XX:+HeapDumpOnOutOfMemoryError

c:\apache-jmeter-3.2\bin>rem Uncomment this if you run JMeter in DOCKER (need Java SE 8u131 or JDK 9)

c:\apache-jmeter-3.2\bin>rem see https://blogs.oracle.com/java-platform-group/java-se-support-for-docker-cpu-and-memory-limits

c:\apache-jmeter-3.2\bin>rem set RUN_IN_DOCKER=-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap

c:\apache-jmeter-3.2\bin>rem Additional settings that might help improve GUI performance on some platforms

c:\apache-jmeter-3.2\bin>rem See: http://www.oracle.com/technetwork/java/perf-graphics-135933.html

c:\apache-jmeter-3.2\bin>if not defined DDRAW (
set DDRAW=
 rem  Setting this flag to true turns off DirectDraw usage, which sometimes helps to get rid of a lot of rendering problems on Win32.
 rem set DDRAW= -Dsun.java2d.noddraw=true
 rem  Setting this flag to false turns off DirectDraw offscreen surfaces acceleration by forcing all createVolatileImage calls to become createImage calls, and disables hidden acceleration performed on surfaces created with createImage .
 rem set DDRAW= -Dsun.java2d.ddoffscreen=false
 rem Setting this flag to true enables hardware-accelerated scaling.
 rem set DDRAW= -Dsun.java2d.ddscale=true
)

c:\apache-jmeter-3.2\bin>rem Collect the settings defined above

c:\apache-jmeter-3.2\bin>if not defined JMETER_COMPLETE_ARGS (set ARGS= -XX:+HeapDumpOnOutOfMemoryError -Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m  -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20  -Djava.security.egd=file:/dev/urandom -Duser.language="en" -Duser.region="EN"  )  else (set ARGS= )

c:\apache-jmeter-3.2\bin>C:\Program Files\Java\jdk1.8.0_162\bin\  -XX:+HeapDumpOnOutOfMemoryError -Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m  -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20  -Djava.security.egd=file:/dev/urandom -Duser.language="en" -Duser.region="EN"   -jar "C:\apache-jmeter-3.2\bin\ApacheJMeter.jar"
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

c:\apache-jmeter-3.2\bin>rem If the errorlevel is not zero, then display it and pause

c:\apache-jmeter-3.2\bin>if NOT errorlevel 0 goto pause

c:\apache-jmeter-3.2\bin>if errorlevel 1 goto pause

c:\apache-jmeter-3.2\bin>echo errorlevel=9009
errorlevel=9009

c:\apache-jmeter-3.2\bin>pause
Press any key to continue . . .
Comment 5 Felix Schumacher 2018-02-17 13:36:22 UTC
Next try to fix this. Can you try this one, too?

Date: Sat Feb 17 13:34:28 2018
New Revision: 1824588

URL: http://svn.apache.org/viewvc?rev=1824588&view=rev
Log:
Put JM_LAUNCH in front, if no JM_START is defined.

Hopefully this fill fix the space problem.

Bugzilla Id: 62107

Modified:
    jmeter/trunk/bin/jmeter.bat
Comment 6 Manu 2018-02-19 03:59:30 UTC
Able to reproduce the issue with the latest fix as well.

c:\apache-jmeter-3.2\bin>jmeter
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
errorlevel=9009
Press any key to continue . . .
c:\apache-jmeter-3.2\bin>

###############
ECHO ON INFO
###############
c:\apache-jmeter-3.2\bin>jmeter

c:\apache-jmeter-3.2\bin>rem   Licensed to the Apache Software Foundation (ASF) under one or more

c:\apache-jmeter-3.2\bin>rem   contributor license agreements.  See the NOTICE file distributed with

c:\apache-jmeter-3.2\bin>rem   this work for additional information regarding copyright ownership.

c:\apache-jmeter-3.2\bin>rem   The ASF licenses this file to You under the Apache License, Version 2.0

c:\apache-jmeter-3.2\bin>rem   (the "License"); you may not use this file except in compliance with

c:\apache-jmeter-3.2\bin>rem   the License.  You may obtain a copy of the License at

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem       http://www.apache.org/licenses/LICENSE-2.0

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   Unless required by applicable law or agreed to in writing, software

c:\apache-jmeter-3.2\bin>rem   distributed under the License is distributed on an "AS IS" BASIS,

c:\apache-jmeter-3.2\bin>rem   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

c:\apache-jmeter-3.2\bin>rem   See the License for the specific language governing permissions and

c:\apache-jmeter-3.2\bin>rem   limitations under the License.

c:\apache-jmeter-3.2\bin>rem   =====================================================

c:\apache-jmeter-3.2\bin>rem   Environment variables that can be defined externally:

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   Do not set the variables in this script. Instead put them into a script

c:\apache-jmeter-3.2\bin>rem   setenv.bat in JMETER_HOME/bin to keep your customizations separate.

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   DDRAW       - (Optional) JVM options to influence usage of direct draw,

c:\apache-jmeter-3.2\bin>rem                 e.g. '-Dsun.java2d.ddscale=true'

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   JMETER_BIN  - JMeter bin directory (must end in \)

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   JMETER_COMPLETE_ARGS - if set indicates that JVM_ARGS is to be used exclusively instead

c:\apache-jmeter-3.2\bin>rem                 of adding other options like HEAP or GC_ALGO

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   JMETER_HOME - installation directory. Will be guessed from location of jmeter.bat

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   JM_LAUNCH   - java.exe (default) or javaw.exe

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   JM_START    - set this to "start" to launch JMeter in a separate window

c:\apache-jmeter-3.2\bin>rem                 this is used by the jmeterw.cmd script.

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   JVM_ARGS    - (Optional) Java options used when starting JMeter, e.g. -Dprop=val

c:\apache-jmeter-3.2\bin>rem                 Defaults to '-Duser.language="en" -Duser.region="EN"'

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   GC_ALGO     - (Optional) JVM garbage collector options

c:\apache-jmeter-3.2\bin>rem                 Defaults to '-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20'

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   HEAP        - (Optional) JVM memory settings used when starting JMeter

c:\apache-jmeter-3.2\bin>rem                 Defaults to '-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m'

c:\apache-jmeter-3.2\bin>rem

c:\apache-jmeter-3.2\bin>rem   =====================================================

c:\apache-jmeter-3.2\bin>setlocal

c:\apache-jmeter-3.2\bin>rem Guess JMETER_HOME if not defined

c:\apache-jmeter-3.2\bin>set "CURRENT_DIR=c:\apache-jmeter-3.2\bin"

c:\apache-jmeter-3.2\bin>if not "" == "" goto gotHome

c:\apache-jmeter-3.2\bin>set "JMETER_HOME=c:\apache-jmeter-3.2\bin"

c:\apache-jmeter-3.2\bin>if exist "c:\apache-jmeter-3.2\bin\bin\jmeter.bat" goto okHome

c:\apache-jmeter-3.2\bin>cd ..

c:\apache-jmeter-3.2>set "JMETER_HOME=c:\apache-jmeter-3.2"

c:\apache-jmeter-3.2>cd "c:\apache-jmeter-3.2\bin"

c:\apache-jmeter-3.2\bin>if exist "c:\apache-jmeter-3.2\bin\jmeter.bat" goto okHome

c:\apache-jmeter-3.2\bin>rem Get standard environment variables

c:\apache-jmeter-3.2\bin>if exist "c:\apache-jmeter-3.2\bin\setenv.bat" call "c:\apache-jmeter-3.2\bin\setenv.bat"

c:\apache-jmeter-3.2\bin>if not defined JMETER_LANGUAGE (
rem Set language
 rem Default to en_EN
 set JMETER_LANGUAGE=-Duser.language="en" -Duser.region="EN"
)

c:\apache-jmeter-3.2\bin>rem Minimal version to run JMeter

c:\apache-jmeter-3.2\bin>set MINIMAL_VERSION=1.8.0

c:\apache-jmeter-3.2\bin>rem --add-modules java.activation if JAVA 9

c:\apache-jmeter-3.2\bin>set JAVA9_OPTS=

c:\apache-jmeter-3.2\bin>for /F "tokens=3" %g in ('java -version 2>&1 | findstr /i "version"') do (
rem @echo Debug Output: %g
 set JAVAVER=%g
)

c:\apache-jmeter-3.2\bin>(
rem @echo Debug Output: "1.8.0_162"
 set JAVAVER="1.8.0_162"
)

c:\apache-jmeter-3.2\bin>if not defined JAVAVER (

 set ERRORLEVEL=2
 goto pause
)

c:\apache-jmeter-3.2\bin>rem Check if version is from OpenJDK or Oracle Hotspot JVM prior to 9 containing 1.${version}.x

c:\apache-jmeter-3.2\bin>rem JAVAVER will be equal to "9.0.4" (quotes are part of the value) for Oracle Java 9

c:\apache-jmeter-3.2\bin>rem JAVAVER will be equal to "1.8.0_161" (quotes are part of the value) for Oracle Java 8

c:\apache-jmeter-3.2\bin>rem so we extract 2 chars starting from index 1

c:\apache-jmeter-3.2\bin>IF "1." == "1." (
set JAVAVER=1.8.0_162
 for /F "delims=. tokens=1-3" %v in (""1.8.0_162"") do (set current_minor=%w )
)  else (
rem Java 9 at least
 set current_minor=9
 set JAVA9_OPTS=--add-modules java.activation --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED
)

c:\apache-jmeter-3.2\bin>(set current_minor=8 )

c:\apache-jmeter-3.2\bin>for /F "delims=. tokens=1-3" %v in ("1.8.0") do (set minimal_minor=%w )

c:\apache-jmeter-3.2\bin>(set minimal_minor=8 )

c:\apache-jmeter-3.2\bin>if not defined current_minor (

 set ERRORLEVEL=2
 goto pause
)

c:\apache-jmeter-3.2\bin>rem @echo Debug: CURRENT=8 - MINIMAL=8

c:\apache-jmeter-3.2\bin>if 8 LSS 8 (

 set ERRORLEVEL=3
 goto pause
)

c:\apache-jmeter-3.2\bin>if not defined JM_LAUNCH (set JM_LAUNCH=java.exe )

c:\apache-jmeter-3.2\bin>if exist jmeter.bat goto winNT1

c:\apache-jmeter-3.2\bin>rem On NT/2K grab all arguments at once

c:\apache-jmeter-3.2\bin>set JMETER_CMD_LINE_ARGS=

c:\apache-jmeter-3.2\bin>rem The following link describes the -XX options:

c:\apache-jmeter-3.2\bin>rem http://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html

c:\apache-jmeter-3.2\bin>if not defined HEAP (
rem See the unix startup file for the rationale of the following parameters,
 rem including some tuning recommendations
 set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m
)

c:\apache-jmeter-3.2\bin>rem Uncomment this to generate GC verbose file with Java prior to 9

c:\apache-jmeter-3.2\bin>rem set VERBOSE_GC=-verbose:gc -Xloggc:gc_jmeter_%p.log -XX:+PrintGCDetails -XX:+PrintGCCause -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintAdaptiveSizePolicy

c:\apache-jmeter-3.2\bin>rem Uncomment this to generate GC verbose file with Java 9 and above

c:\apache-jmeter-3.2\bin>rem set VERBOSE_GC=-Xlog:gc*,gc+age=trace,gc+heap=debug:file=gc_jmeter_%p.log

c:\apache-jmeter-3.2\bin>rem You may want to add those settings

c:\apache-jmeter-3.2\bin>rem -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem

c:\apache-jmeter-3.2\bin>if not defined GC_ALGO (set GC_ALGO=-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 )

c:\apache-jmeter-3.2\bin>set SYSTEM_PROPS=-Djava.security.egd=file:/dev/urandom

c:\apache-jmeter-3.2\bin>rem Always dump on OOM (does not cost anything unless triggered)

c:\apache-jmeter-3.2\bin>set DUMP=-XX:+HeapDumpOnOutOfMemoryError

c:\apache-jmeter-3.2\bin>rem Uncomment this if you run JMeter in DOCKER (need Java SE 8u131 or JDK 9)

c:\apache-jmeter-3.2\bin>rem see https://blogs.oracle.com/java-platform-group/java-se-support-for-docker-cpu-and-memory-limits

c:\apache-jmeter-3.2\bin>rem set RUN_IN_DOCKER=-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap

c:\apache-jmeter-3.2\bin>rem Additional settings that might help improve GUI performance on some platforms

c:\apache-jmeter-3.2\bin>rem See: http://www.oracle.com/technetwork/java/perf-graphics-135933.html

c:\apache-jmeter-3.2\bin>if not defined DDRAW (
set DDRAW=
 rem  Setting this flag to true turns off DirectDraw usage, which sometimes helps to get rid of a lot of rendering problems on Win32.
 rem set DDRAW= -Dsun.java2d.noddraw=true
 rem  Setting this flag to false turns off DirectDraw offscreen surfaces acceleration by forcing all createVolatileImage calls to become createImage calls, and disables hidden acceleration performed on surfaces created with createImage .
 rem set DDRAW= -Dsun.java2d.ddoffscreen=false
 rem Setting this flag to true enables hardware-accelerated scaling.
 rem set DDRAW= -Dsun.java2d.ddscale=true
)

c:\apache-jmeter-3.2\bin>rem Collect the settings defined above

c:\apache-jmeter-3.2\bin>if not defined JMETER_COMPLETE_ARGS (set ARGS= -XX:+HeapDumpOnOutOfMemoryError -Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m  -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20  -Djava.security.egd=file:/dev/urandom -Duser.language="en" -Duser.region="EN"  )  else (set ARGS= )

c:\apache-jmeter-3.2\bin>if defined JM_START (set "_JM_START= C:\Program Files\Java\jdk1.8.0_162\bin\" )  else (set "_JM_START=C:\Program Files\Java\jdk1.8.0_162\bin\" )

c:\apache-jmeter-3.2\bin>C:\Program Files\Java\jdk1.8.0_162\bin\  -XX:+HeapDumpOnOutOfMemoryError -Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m  -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20  -Djava.security.egd=file:/dev/urandom -Duser.language="en" -Duser.region="EN"   -jar "C:\apache-jmeter-3.2\bin\ApacheJMeter.jar"
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

c:\apache-jmeter-3.2\bin>rem If the errorlevel is not zero, then display it and pause

c:\apache-jmeter-3.2\bin>if NOT errorlevel 0 goto pause

c:\apache-jmeter-3.2\bin>if errorlevel 1 goto pause

c:\apache-jmeter-3.2\bin>echo errorlevel=9009
errorlevel=9009

c:\apache-jmeter-3.2\bin>pause
Press any key to continue . . .
c:\apache-jmeter-3.2\bin>
Comment 7 Manu 2018-02-19 04:00:50 UTC
(In reply to Felix Schumacher from comment #5)
> Next try to fix this. Can you try this one, too?
> 
> Date: Sat Feb 17 13:34:28 2018
> New Revision: 1824588
> 
> URL: http://svn.apache.org/viewvc?rev=1824588&view=rev
> Log:
> Put JM_LAUNCH in front, if no JM_START is defined.
> 
> Hopefully this fill fix the space problem.
> 
> Bugzilla Id: 62107
> 
> Modified:
>     jmeter/trunk/bin/jmeter.bat

I took the corresponding bat from trunk and tried but it failed.
Comment 8 Antonio Gomes Rodrigues 2018-02-19 10:02:00 UTC
Hi,

Have you try with release 4.0 of JMeter?

In my Windows machine (Windows 10), I have no problem

Antonio
Comment 9 Felix Schumacher 2018-02-19 12:51:00 UTC
The question for me is: how do you set JM_LAUNCH?
Comment 10 Felix Schumacher 2018-02-19 18:15:39 UTC
I have tested this (and the ones before) with the following setup:

> set "JM_LAUNCH=C:\PATH WITH SPACES\java"
> jmeter.bat

Date: Mon Feb 19 18:13:45 2018
New Revision: 1824800

URL: http://svn.apache.org/viewvc?rev=1824800&view=rev
Log:
Use quotes around JM_LAUNCH and add a title to JM_START

Hopefully this will fix the space problem.

Bugzilla Id: 62107

Modified:
    jmeter/trunk/bin/jmeter.bat
    jmeter/trunk/bin/jmeterw.cmd
Comment 11 Manu 2018-02-20 01:21:01 UTC
(In reply to Felix Schumacher from comment #9)
> The question for me is: how do you set JM_LAUNCH?

In the Environment variables >> user/system variables.

JM_LAUNCH = C:\Program Files\Java\jdk1.8.0_162\bin\
Comment 12 Manu 2018-02-20 01:23:17 UTC
(In reply to Felix Schumacher from comment #10)
> I have tested this (and the ones before) with the following setup:
> 
> > set "JM_LAUNCH=C:\PATH WITH SPACES\java"
> > jmeter.bat
> 
> Date: Mon Feb 19 18:13:45 2018
> New Revision: 1824800
> 
> URL: http://svn.apache.org/viewvc?rev=1824800&view=rev
> Log:
> Use quotes around JM_LAUNCH and add a title to JM_START
> 
> Hopefully this will fix the space problem.
> 
> Bugzilla Id: 62107
> 
> Modified:
>     jmeter/trunk/bin/jmeter.bat
>     jmeter/trunk/bin/jmeterw.cmd

I tried that, hardcording JM_LAUNCH="C:\Program Files\Java\jdk1.8.0_162\bin\java" within jmeter.bat and it worked. However I believe it should work as part of the environment variable settings as well.
Comment 13 Manu 2018-02-20 01:25:10 UTC
(In reply to Antonio Gomes Rodrigues from comment #8)
> Hi,
> 
> Have you try with release 4.0 of JMeter?
> 
> In my Windows machine (Windows 10), I have no problem
> 
> Antonio

Actually first I tried with 4.0 version. Then I moved to 3.2. Did you hardcode the JM_LAUNCH path within jmeter.bat?
Comment 14 Felix Schumacher 2018-02-20 12:01:21 UTC
(In reply to Manu from comment #12)
> (In reply to Felix Schumacher from comment #10)
> > I have tested this (and the ones before) with the following setup:
> > 
> > > set "JM_LAUNCH=C:\PATH WITH SPACES\java"
> > > jmeter.bat
> > 
> > Date: Mon Feb 19 18:13:45 2018
> > New Revision: 1824800
> > 
> > URL: http://svn.apache.org/viewvc?rev=1824800&view=rev
> > Log:
> > Use quotes around JM_LAUNCH and add a title to JM_START
> > 
> > Hopefully this will fix the space problem.
> > 
> > Bugzilla Id: 62107
> > 
> > Modified:
> >     jmeter/trunk/bin/jmeter.bat
> >     jmeter/trunk/bin/jmeterw.cmd
> 
> I tried that, hardcording JM_LAUNCH="C:\Program
> Files\Java\jdk1.8.0_162\bin\java" within jmeter.bat and it worked. However I
> believe it should work as part of the environment variable settings as well.

Instead of editing jmeter.bat you could create a setenv.bat and place it there. Note that I used 'set "var=value"' 

Have you tried again with the current version? 

Does the current version work with the environment variable?
Comment 15 Manu 2018-02-20 13:55:06 UTC
(In reply to Felix Schumacher from comment #14)
> (In reply to Manu from comment #12)
> > (In reply to Felix Schumacher from comment #10)
> > > I have tested this (and the ones before) with the following setup:
> > > 
> > > > set "JM_LAUNCH=C:\PATH WITH SPACES\java"
> > > > jmeter.bat
> > > 
> > > Date: Mon Feb 19 18:13:45 2018
> > > New Revision: 1824800
> > > 
> > > URL: http://svn.apache.org/viewvc?rev=1824800&view=rev
> > > Log:
> > > Use quotes around JM_LAUNCH and add a title to JM_START
> > > 
> > > Hopefully this will fix the space problem.
> > > 
> > > Bugzilla Id: 62107
> > > 
> > > Modified:
> > >     jmeter/trunk/bin/jmeter.bat
> > >     jmeter/trunk/bin/jmeterw.cmd
> > 
> > I tried that, hardcording JM_LAUNCH="C:\Program
> > Files\Java\jdk1.8.0_162\bin\java" within jmeter.bat and it worked. However I
> > believe it should work as part of the environment variable settings as well.
> 
> Instead of editing jmeter.bat you could create a setenv.bat and place it
> there. Note that I used 'set "var=value"' 
> 
> Have you tried again with the current version? 
> 
> Does the current version work with the environment variable?

Yes setting the JM_LAUNCH with setenv.bat as well its working..
I tried it with 3.2 and 4.0 version.
However the actual issue is that if I set JM_LAUNCH in Environment Variables >> user variable it's breaking due to space on launch. This is observed with 4.0 as well.

C:\apache-jmeter-4.0\bin>jmeter

C:\apache-jmeter-4.0\bin>rem   Licensed to the Apache Software Foundation (ASF) under one or more

C:\apache-jmeter-4.0\bin>rem   contributor license agreements.  See the NOTICE file distributed with

C:\apache-jmeter-4.0\bin>rem   this work for additional information regarding copyright ownership.

C:\apache-jmeter-4.0\bin>rem   The ASF licenses this file to You under the Apache License, Version 2.0

C:\apache-jmeter-4.0\bin>rem   (the "License"); you may not use this file except in compliance with

C:\apache-jmeter-4.0\bin>rem   the License.  You may obtain a copy of the License at

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem       http://www.apache.org/licenses/LICENSE-2.0

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   Unless required by applicable law or agreed to in writing, software

C:\apache-jmeter-4.0\bin>rem   distributed under the License is distributed on an "AS IS" BASIS,

C:\apache-jmeter-4.0\bin>rem   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

C:\apache-jmeter-4.0\bin>rem   See the License for the specific language governing permissions and

C:\apache-jmeter-4.0\bin>rem   limitations under the License.

C:\apache-jmeter-4.0\bin>rem   =====================================================

C:\apache-jmeter-4.0\bin>rem   Environment variables that can be defined externally:

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   Do not set the variables in this script. Instead put them into a script

C:\apache-jmeter-4.0\bin>rem   setenv.bat in JMETER_HOME/bin to keep your customizations separate.

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   DDRAW       - (Optional) JVM options to influence usage of direct draw,

C:\apache-jmeter-4.0\bin>rem                 e.g. '-Dsun.java2d.ddscale=true'

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   JMETER_BIN  - JMeter bin directory (must end in \)

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   JMETER_COMPLETE_ARGS - if set indicates that JVM_ARGS is to be used exclusively instead

C:\apache-jmeter-4.0\bin>rem                 of adding other options like HEAP or GC_ALGO

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   JMETER_HOME - installation directory. Will be guessed from location of jmeter.bat

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   JM_LAUNCH   - java.exe (default) or javaw.exe

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   JM_START    - set this to "start" to launch JMeter in a separate window

C:\apache-jmeter-4.0\bin>rem                 this is used by the jmeterw.cmd script.

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   JVM_ARGS    - (Optional) Java options used when starting JMeter, e.g. -Dprop=val

C:\apache-jmeter-4.0\bin>rem                 Defaults to '-Duser.language="en" -Duser.region="EN"'

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   GC_ALGO     - (Optional) JVM garbage collector options

C:\apache-jmeter-4.0\bin>rem                 Defaults to '-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20'

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   HEAP        - (Optional) JVM memory settings used when starting JMeter

C:\apache-jmeter-4.0\bin>rem                 Defaults to '-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m'

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   =====================================================

C:\apache-jmeter-4.0\bin>setlocal

C:\apache-jmeter-4.0\bin>rem Guess JMETER_HOME if not defined

C:\apache-jmeter-4.0\bin>set "CURRENT_DIR=C:\apache-jmeter-4.0\bin"

C:\apache-jmeter-4.0\bin>if not "" == "" goto gotHome

C:\apache-jmeter-4.0\bin>set "JMETER_HOME=C:\apache-jmeter-4.0\bin"

C:\apache-jmeter-4.0\bin>if exist "C:\apache-jmeter-4.0\bin\bin\jmeter.bat" goto okHome

C:\apache-jmeter-4.0\bin>cd ..

C:\apache-jmeter-4.0>set "JMETER_HOME=C:\apache-jmeter-4.0"

C:\apache-jmeter-4.0>cd "C:\apache-jmeter-4.0\bin"

C:\apache-jmeter-4.0\bin>if exist "C:\apache-jmeter-4.0\bin\jmeter.bat" goto okHome

C:\apache-jmeter-4.0\bin>rem Get standard environment variables

C:\apache-jmeter-4.0\bin>if exist "C:\apache-jmeter-4.0\bin\setenv.bat" call "C:\apache-jmeter-4.0\bin\setenv.bat"

C:\apache-jmeter-4.0\bin>if not defined JMETER_LANGUAGE (
rem Set language
 rem Default to en_EN
 set JMETER_LANGUAGE=-Duser.language="en" -Duser.region="EN"
)

C:\apache-jmeter-4.0\bin>rem Minimal version to run JMeter

C:\apache-jmeter-4.0\bin>set MINIMAL_VERSION=1.8.0

C:\apache-jmeter-4.0\bin>rem --add-modules java.activation if JAVA 9

C:\apache-jmeter-4.0\bin>set JAVA9_OPTS=

C:\apache-jmeter-4.0\bin>for /F "tokens=3" %g in ('java -version 2>&1 | findstr /i "version"') do (
rem @echo Debug Output: %g
 set JAVAVER=%g
)

C:\apache-jmeter-4.0\bin>(
rem @echo Debug Output: "1.8.0_162"
 set JAVAVER="1.8.0_162"
)

C:\apache-jmeter-4.0\bin>if not defined JAVAVER (

 set ERRORLEVEL=2
 goto pause
)

C:\apache-jmeter-4.0\bin>rem Check if version is from OpenJDK or Oracle Hotspot JVM prior to 9 containing 1.${version}.x

C:\apache-jmeter-4.0\bin>rem JAVAVER will be equal to "9.0.4" (quotes are part of the value) for Oracle Java 9

C:\apache-jmeter-4.0\bin>rem JAVAVER will be equal to "1.8.0_161" (quotes are part of the value) for Oracle Java 8

C:\apache-jmeter-4.0\bin>rem so we extract 2 chars starting from index 1

C:\apache-jmeter-4.0\bin>IF "1." == "1." (
set JAVAVER=1.8.0_162
 for /F "delims=. tokens=1-3" %v in (""1.8.0_162"") do (set current_minor=%w )
)  else (
rem Java 9 at least
 set current_minor=9
 set JAVA9_OPTS=--add-modules java.activation --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED
)

C:\apache-jmeter-4.0\bin>(set current_minor=8 )

C:\apache-jmeter-4.0\bin>for /F "delims=. tokens=1-3" %v in ("1.8.0") do (set minimal_minor=%w )

C:\apache-jmeter-4.0\bin>(set minimal_minor=8 )

C:\apache-jmeter-4.0\bin>if not defined current_minor (

 set ERRORLEVEL=2
 goto pause
)

C:\apache-jmeter-4.0\bin>rem @echo Debug: CURRENT=8 - MINIMAL=8

C:\apache-jmeter-4.0\bin>if 8 LSS 8 (

 set ERRORLEVEL=3
 goto pause
)
Files\Java\jdk1.8.0_162\bin\ was unexpected at this time.
C:\apache-jmeter-4.0\bin>if .C:\Program Files\Java\jdk1.8.0_162\bin\ == . set JM_LAUNCH=java.exe
C:\apache-jmeter-4.0\bin>
Comment 16 Felix Schumacher 2018-02-20 16:08:53 UTC
Is the current version from subversion working for you, when you use the environment variable?
Comment 17 Manu 2018-02-21 04:46:25 UTC
(In reply to Felix Schumacher from comment #16)
> Is the current version from subversion working for you, when you use the
> environment variable?

When I use environment variable with setenv.bat it's working.
When I set JM_LAUNCH on windows environment variables setting it's not working.

I tested the jmeter.bat from http://svn.apache.org/viewvc/jmeter/branches/docs-4.0/bin/jmeter.bat?view=log
as well
Comment 18 Felix Schumacher 2018-02-21 05:47:28 UTC
The changes are made in trunk, please try http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.bat?view=log
Comment 19 Manu 2018-02-21 11:12:56 UTC
(In reply to Felix Schumacher from comment #18)
> The changes are made in trunk, please try
> http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter.bat?view=log

I was testing with your fixes available in trunk and updating here. I just retested again. With windows environment variable settings for JM_LAUNCH it's not working. It's working only if I set it in setenv.bat

C:\apache-jmeter-4.0\bin>jmeter
'"C:\Program Files\Java\jdk1.8.0_162\bin\"' is not recognized as an internal or external command,
operable program or batch file.
errorlevel=9009
Press any key to continue . . .
C:\apache-jmeter-4.0\bin>jmeter

C:\apache-jmeter-4.0\bin>rem   Licensed to the Apache Software Foundation (ASF) under one or more

C:\apache-jmeter-4.0\bin>rem   contributor license agreements.  See the NOTICE file distributed with

C:\apache-jmeter-4.0\bin>rem   this work for additional information regarding copyright ownership.

C:\apache-jmeter-4.0\bin>rem   The ASF licenses this file to You under the Apache License, Version 2.0

C:\apache-jmeter-4.0\bin>rem   (the "License"); you may not use this file except in compliance with

C:\apache-jmeter-4.0\bin>rem   the License.  You may obtain a copy of the License at

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem       http://www.apache.org/licenses/LICENSE-2.0

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   Unless required by applicable law or agreed to in writing, software

C:\apache-jmeter-4.0\bin>rem   distributed under the License is distributed on an "AS IS" BASIS,

C:\apache-jmeter-4.0\bin>rem   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

C:\apache-jmeter-4.0\bin>rem   See the License for the specific language governing permissions and

C:\apache-jmeter-4.0\bin>rem   limitations under the License.

C:\apache-jmeter-4.0\bin>rem   =====================================================

C:\apache-jmeter-4.0\bin>rem   Environment variables that can be defined externally:

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   Do not set the variables in this script. Instead put them into a script

C:\apache-jmeter-4.0\bin>rem   setenv.bat in JMETER_HOME/bin to keep your customizations separate.

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   DDRAW       - (Optional) JVM options to influence usage of direct draw,

C:\apache-jmeter-4.0\bin>rem                 e.g. '-Dsun.java2d.ddscale=true'

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   JMETER_BIN  - JMeter bin directory (must end in \)

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   JMETER_COMPLETE_ARGS - if set indicates that JVM_ARGS is to be used exclusively instead

C:\apache-jmeter-4.0\bin>rem                 of adding other options like HEAP or GC_ALGO

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   JMETER_HOME - installation directory. Will be guessed from location of jmeter.bat

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   JM_LAUNCH   - java.exe (default) or javaw.exe

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   JM_START    - set this to "start" to launch JMeter in a separate window

C:\apache-jmeter-4.0\bin>rem                 this is used by the jmeterw.cmd script.

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   JVM_ARGS    - (Optional) Java options used when starting JMeter, e.g. -Dprop=val

C:\apache-jmeter-4.0\bin>rem                 Defaults to '-Duser.language="en" -Duser.region="EN"'

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   GC_ALGO     - (Optional) JVM garbage collector options

C:\apache-jmeter-4.0\bin>rem                 Defaults to '-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20'

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   HEAP        - (Optional) JVM memory settings used when starting JMeter

C:\apache-jmeter-4.0\bin>rem                 Defaults to '-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m'

C:\apache-jmeter-4.0\bin>rem

C:\apache-jmeter-4.0\bin>rem   =====================================================

C:\apache-jmeter-4.0\bin>setlocal

C:\apache-jmeter-4.0\bin>rem Guess JMETER_HOME if not defined

C:\apache-jmeter-4.0\bin>set "CURRENT_DIR=C:\apache-jmeter-4.0\bin"

C:\apache-jmeter-4.0\bin>if not "" == "" goto gotHome

C:\apache-jmeter-4.0\bin>set "JMETER_HOME=C:\apache-jmeter-4.0\bin"

C:\apache-jmeter-4.0\bin>if exist "C:\apache-jmeter-4.0\bin\bin\jmeter.bat" goto okHome

C:\apache-jmeter-4.0\bin>cd ..

C:\apache-jmeter-4.0>set "JMETER_HOME=C:\apache-jmeter-4.0"

C:\apache-jmeter-4.0>cd "C:\apache-jmeter-4.0\bin"

C:\apache-jmeter-4.0\bin>if exist "C:\apache-jmeter-4.0\bin\jmeter.bat" goto okHome

C:\apache-jmeter-4.0\bin>rem Get standard environment variables

C:\apache-jmeter-4.0\bin>if exist "C:\apache-jmeter-4.0\bin\setenv.bat" call "C:\apache-jmeter-4.0\bin\setenv.bat"

C:\apache-jmeter-4.0\bin>if not defined JMETER_LANGUAGE (
rem Set language
 rem Default to en_EN
 set JMETER_LANGUAGE=-Duser.language="en" -Duser.region="EN"
)

C:\apache-jmeter-4.0\bin>rem Minimal version to run JMeter

C:\apache-jmeter-4.0\bin>set MINIMAL_VERSION=1.8.0

C:\apache-jmeter-4.0\bin>rem --add-modules java.activation if JAVA 9

C:\apache-jmeter-4.0\bin>set JAVA9_OPTS=

C:\apache-jmeter-4.0\bin>for /F "tokens=3" %g in ('java -version 2>&1 | findstr /i "version"') do (
rem @echo Debug Output: %g
 set JAVAVER=%g
)

C:\apache-jmeter-4.0\bin>(
rem @echo Debug Output: "1.8.0_162"
 set JAVAVER="1.8.0_162"
)

C:\apache-jmeter-4.0\bin>if not defined JAVAVER (

 set ERRORLEVEL=2
 goto pause
)

C:\apache-jmeter-4.0\bin>rem Check if version is from OpenJDK or Oracle Hotspot JVM prior to 9 containing 1.${version}.x

C:\apache-jmeter-4.0\bin>rem JAVAVER will be equal to "9.0.4" (quotes are part of the value) for Oracle Java 9

C:\apache-jmeter-4.0\bin>rem JAVAVER will be equal to "1.8.0_161" (quotes are part of the value) for Oracle Java 8

C:\apache-jmeter-4.0\bin>rem so we extract 2 chars starting from index 1

C:\apache-jmeter-4.0\bin>IF "1." == "1." (
set JAVAVER=1.8.0_162
 for /F "delims=. tokens=1-3" %v in (""1.8.0_162"") do (set current_minor=%w )
)  else (
rem Java 9 at least
 set current_minor=9
 set JAVA9_OPTS=--add-modules java.activation --add-opens java.desktop/sun.awt=ALL-UNNAMED --add-opens java.desktop/sun.swing=ALL-UNNAMED --add-opens java.desktop/javax.swing.text.html=ALL-UNNAMED --add-opens java.desktop/java.awt=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.text=ALL-UNNAMED
)

C:\apache-jmeter-4.0\bin>(set current_minor=8 )

C:\apache-jmeter-4.0\bin>for /F "delims=. tokens=1-3" %v in ("1.8.0") do (set minimal_minor=%w )

C:\apache-jmeter-4.0\bin>(set minimal_minor=8 )

C:\apache-jmeter-4.0\bin>if not defined current_minor (

 set ERRORLEVEL=2
 goto pause
)

C:\apache-jmeter-4.0\bin>rem @echo Debug: CURRENT=8 - MINIMAL=8

C:\apache-jmeter-4.0\bin>if 8 LSS 8 (

 set ERRORLEVEL=3
 goto pause
)

C:\apache-jmeter-4.0\bin>if not defined JM_LAUNCH (set JM_LAUNCH=java.exe )

C:\apache-jmeter-4.0\bin>if exist jmeter.bat goto winNT1

C:\apache-jmeter-4.0\bin>rem On NT/2K grab all arguments at once

C:\apache-jmeter-4.0\bin>set JMETER_CMD_LINE_ARGS=

C:\apache-jmeter-4.0\bin>rem The following link describes the -XX options:

C:\apache-jmeter-4.0\bin>rem http://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html

C:\apache-jmeter-4.0\bin>if not defined HEAP (
rem See the unix startup file for the rationale of the following parameters,
 rem including some tuning recommendations
 set HEAP=-Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m
)

C:\apache-jmeter-4.0\bin>rem Uncomment this to generate GC verbose file with Java prior to 9

C:\apache-jmeter-4.0\bin>rem set VERBOSE_GC=-verbose:gc -Xloggc:gc_jmeter_%p.log -XX:+PrintGCDetails -XX:+PrintGCCause -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintAdaptiveSizePolicy

C:\apache-jmeter-4.0\bin>rem Uncomment this to generate GC verbose file with Java 9 and above

C:\apache-jmeter-4.0\bin>rem set VERBOSE_GC=-Xlog:gc*,gc+age=trace,gc+heap=debug:file=gc_jmeter_%p.log

C:\apache-jmeter-4.0\bin>rem You may want to add those settings

C:\apache-jmeter-4.0\bin>rem -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem

C:\apache-jmeter-4.0\bin>if not defined GC_ALGO (set GC_ALGO=-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 )

C:\apache-jmeter-4.0\bin>set SYSTEM_PROPS=-Djava.security.egd=file:/dev/urandom

C:\apache-jmeter-4.0\bin>rem Always dump on OOM (does not cost anything unless triggered)

C:\apache-jmeter-4.0\bin>set DUMP=-XX:+HeapDumpOnOutOfMemoryError

C:\apache-jmeter-4.0\bin>rem Uncomment this if you run JMeter in DOCKER (need Java SE 8u131 or JDK 9)

C:\apache-jmeter-4.0\bin>rem see https://blogs.oracle.com/java-platform-group/java-se-support-for-docker-cpu-and-memory-limits

C:\apache-jmeter-4.0\bin>rem set RUN_IN_DOCKER=-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap

C:\apache-jmeter-4.0\bin>rem Additional settings that might help improve GUI performance on some platforms

C:\apache-jmeter-4.0\bin>rem See: http://www.oracle.com/technetwork/java/perf-graphics-135933.html

C:\apache-jmeter-4.0\bin>if not defined DDRAW (
set DDRAW=
 rem  Setting this flag to true turns off DirectDraw usage, which sometimes helps to get rid of a lot of rendering problems on Win32.
 rem set DDRAW= -Dsun.java2d.noddraw=true
 rem  Setting this flag to false turns off DirectDraw offscreen surfaces acceleration by forcing all createVolatileImage calls to become createImage calls, and disables hidden acceleration performed on surfaces created with createImage .
 rem set DDRAW= -Dsun.java2d.ddoffscreen=false
 rem Setting this flag to true enables hardware-accelerated scaling.
 rem set DDRAW= -Dsun.java2d.ddscale=true
)

C:\apache-jmeter-4.0\bin>rem Collect the settings defined above

C:\apache-jmeter-4.0\bin>if not defined JMETER_COMPLETE_ARGS (set ARGS= -XX:+HeapDumpOnOutOfMemoryError -Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m  -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20  -Djava.security.egd=file:/dev/urandom -Duser.language="en" -Duser.region="EN"  )  else (set ARGS= )

C:\apache-jmeter-4.0\bin>"C:\Program Files\Java\jdk1.8.0_162\bin\"  -XX:+HeapDumpOnOutOfMemoryError -Xms1g -Xmx1g -XX:MaxMetaspaceSize=256m  -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20  -Djava.security.egd=file:/dev/urandom -Duser.language="en" -Duser.region="EN"   -jar "C:\apache-jmeter-4.0\bin\ApacheJMeter.jar"
'"C:\Program Files\Java\jdk1.8.0_162\bin\"' is not recognized as an internal or external command,
operable program or batch file.

C:\apache-jmeter-4.0\bin>rem If the errorlevel is not zero, then display it and pause

C:\apache-jmeter-4.0\bin>if NOT errorlevel 0 goto pause

C:\apache-jmeter-4.0\bin>if errorlevel 1 goto pause

C:\apache-jmeter-4.0\bin>echo errorlevel=9009
errorlevel=9009

C:\apache-jmeter-4.0\bin>pause
Press any key to continue . . .
C:\apache-jmeter-4.0\bin>
Comment 20 Felix Schumacher 2018-02-21 12:28:19 UTC
It is really strange that the string java is missing if you use the environment variable. Can you double check that it is really part of your environment variable?
Comment 21 Manu 2018-02-21 14:33:23 UTC
(In reply to Felix Schumacher from comment #20)
> It is really strange that the string java is missing if you use the
> environment variable. Can you double check that it is really part of your
> environment variable?

Oops.. I thought we don't need to specify the executable name.. only the path till bin is required. sorry if that's the case.
Comment 22 Felix Schumacher 2018-02-21 17:58:57 UTC
The variable JM_LAUNCH has to point to a valid executable. So either a PATH relative name or an absolute name is OK.

Is the current trunk bat working for you with environment variable (and with 'set "JM_LAUNCH=...\java"')?
Comment 23 Manu 2018-02-22 01:02:49 UTC
(In reply to Felix Schumacher from comment #22)
> The variable JM_LAUNCH has to point to a valid executable. So either a PATH
> relative name or an absolute name is OK.
> 
> Is the current trunk bat working for you with environment variable (and with
> 'set "JM_LAUNCH=...\java"')?

yes it's working after providing the environment variable in windows setting as JM_LAUNCH="C:\Program Files\Java\jdk1.8.0_162\bin\java". Also it works when we set it in setenv.bat
Comment 24 logox01 2018-02-26 08:59:28 UTC
I'm currently getting an error (errorcode 5) when I try to start JMeter (4.1 r1825328) using the jmeter.bat file.

The reason seems to be the quotes around the JM_LAUNCH variable (if JM_START="start"):

%JM_START% "%JM_LAUNCH%" %ARGS% %JVM_ARGS% -jar "%JMETER_BIN%ApacheJMeter.jar" %JMETER_CMD_LINE_ARGS%

Without the quotes it is working:

%JM_START% %JM_LAUNCH% %ARGS% %JVM_ARGS% -jar "%JMETER_BIN%ApacheJMeter.jar" %JMETER_CMD_LINE_ARGS%

BR
Comment 25 Felix Schumacher 2018-02-26 11:13:09 UTC
The variable JM_START must be 'start "empty or title"'. For n exsample look at jmeter.bat.

If you know of a better solution for this bug, you are welcomed to produce a patch :)
Comment 26 logox01 2018-02-27 10:54:15 UTC
In jmeter.bat it's described like this:

rem   JM_START    - set this to "start" to launch JMeter in a separate window
rem                 this is used by the jmeterw.cmd script.

But in jmeterw.cmd it's used like you said - and it works if I use it like this :)

Thanks
Comment 27 Felix Schumacher 2018-02-27 10:59:28 UTC
Seems like we have to adapt the description of add a special case of start is used without a title.
Comment 28 Felix Schumacher 2018-03-04 11:09:19 UTC
Date: Sun Mar  4 11:07:49 2018
New Revision: 1825804

URL: http://svn.apache.org/viewvc?rev=1825804&view=rev
Log:
Enable starting of jmeter.bat with JM_START set to "start"

Correct documentation for usage of JM_START to start JMeter.
Add a title to 'start' when none was given, which can happen,
when following old documentation.

Bugzilla Id: 62107

Modified:
    jmeter/trunk/bin/jmeter.bat
Comment 29 Felix Schumacher 2018-09-06 17:08:25 UTC
Date: Thu Sep  6 17:00:22 2018
New Revision: 1840236

URL: http://svn.apache.org/viewvc?rev=1840236&view=rev
Log:
Spaces and quotes will confuse windows batch files

As reported on the mailing list the space in quotes for the window title
will confuse the windows batch interpreter. Quotes alone seem to be OK, though.
Therefore we use an underscore instead of the space in the window title.

Follow-up to r1824800 and relates to Bugzilla Id: 62107

Modified:
    jmeter/trunk/bin/jmeter.bat
    jmeter/trunk/bin/jmeterw.cmd