Bug 59052 - jmeter.bat don't use the JM_LAUNCH to test java version, so java versions could be different
Summary: jmeter.bat don't use the JM_LAUNCH to test java version, so java versions cou...
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 3.0
Hardware: PC All
: P2 minor with 1 vote (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
Depends on:
Reported: 2016-02-23 12:33 UTC by vdaburon
Modified: 2016-05-31 20:32 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description vdaburon 2016-02-23 12:33:19 UTC

You could set the JM_LAUNCH but this information is not used to detected the java version, so JM_LAUNCH and 'java' could have differents versions

rem   JM_LAUNCH - java.exe (default) or javaw.exe

set JM_LAUNCH=d:\java\jdk1.7

but the java -version 2^>^&1 use the version in the PATH not the JM_LAUNCH

for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do (
    rem @echo Debug Output: %%g
    set JAVAVER=%%g

Vincent D.
Comment 1 Sebb 2016-02-24 21:54:31 UTC
It's clear from the comment that JM_LAUNCH is the executable name, and does not include the PATH.

Other usage is not supported/
Comment 2 Frank 2016-05-31 20:32:05 UTC
I second this. 

It is usual that the JDK or JRE present in the PATH of the system is not the one used to run JMeter. And I know you can copy the jmeter.bat and modify it yourself but this can be easily fixed moving one line in the jmeter.bat file:

Line 64: if .%JM_LAUNCH% == . set JM_LAUNCH=java.exe <-- Move this to line 33 

And changing this:
Line 34: for /f "tokens=3" %%g in ('java -version 2^>^&1 ^| findstr /i "version"') do (


for /f "tokens=3" %%g in ('%JM_LAUNCH% -version 2^>^&1 ^| findstr /i "version"') do (

So the new would look like:

Line 33: if .%JM_LAUNCH% == . set JM_LAUNCH=java.exe
Line 34: for /f "tokens=3" %%g in ('%JM_LAUNCH% -version 2^>^&1 ^| findstr /i "version"') do (

Then you can set JM_LAUNCH to use a full path (i.e JM_LAUNCH=C:\myjdk\bin\java.exe) and it works perfectly (winxp, win7, winserver2012 at least).

Is not a big deal but simplifies the execution when having multiple JDKs
Comment 3 The ASF infrastructure team 2022-09-24 20:38:02 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/3850