You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2017/11/04 19:32:46 UTC

svn commit: r1814316 - /jmeter/trunk/bin/jmeter

Author: fschumacher
Date: Sat Nov  4 19:32:46 2017
New Revision: 1814316

URL: http://svn.apache.org/viewvc?rev=1814316&view=rev
Log:
Try to detect the version of java by removing a potentially existing string "1." from
the start of the version string and all characters beginning with the first non digit.

This will convert a java 8 version string like "1.8.144_91" to "8" and a java 9 version
string like "9-ea" to "9"

Followup to r1813017
Bugzilla Id: 61529

Modified:
    jmeter/trunk/bin/jmeter

Modified: jmeter/trunk/bin/jmeter
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/jmeter?rev=1814316&r1=1814315&r2=1814316&view=diff
==============================================================================
--- jmeter/trunk/bin/jmeter (original)
+++ jmeter/trunk/bin/jmeter Sat Nov  4 19:32:46 2017
@@ -67,19 +67,14 @@ fi
 ADD_MODS=
 
 # Minimal version to run JMeter
-MINIMAL_VERSION=1.8.0
+MINIMAL_VERSION=8
 
 _java=`type java | awk '{ print $ NF }'`
-CURRENT_VERSION=`"$_java" -version 2>&1 | awk -F'"' '/version/ {print $2}'`
 # Check if version is from OpenJDK or Oracle Hotspot JVM prior to 9 containing 1.${version}.x
-if [ ${#CURRENT_VERSION} -lt 1 ]; then
-    CURRENT_VERSION=`echo $CURRENT_VERSION | awk -F'.' '{ print $2 }'`
-else
-    MINIMAL_VERSION=`echo $MINIMAL_VERSION | awk -F'.' '{ print $2 }'`
-fi
+CURRENT_VERSION=`"$_java" -version 2>&1 | awk -F'"' '/version/ {gsub("^1[.]", "", $2); gsub("[^0-9].*$", "", $2); print $2}'`
 
 # Check if Java is present and the minimal version requirement
-if [ $CURRENT_VERSION -gt $MINIMAL_VERSION ]; then
+if [ "$CURRENT_VERSION" -gt "$MINIMAL_VERSION" ]; then
     ADD_MODS="--add-modules java.activation"
 fi