#1061059 javaws.sh fails to determine java version if extra java options exist

#1061059#5
Date:
2024-01-17 07:39:10 UTC
From:
To:
I pass some extra scaling option on my system to JAVA so i can actually
read something on a 4K laptop display so the <java_bin> -version call in
javaws.sh receives a string like

'Picked up JAVA_TOOL_OPTIONS: -Dsun.java2d.uiScale=2.0 openjdk version
"11.0.20"...'

on my system resulting in the cut sequence to fail which is supposed to
determine the java version number to set MODULAR_JDK=(YES|NO).
I can imagine that it's a challenge to get an easy solution working with
any java to extract the java version number.

I might be the only one doing something like that, but I can imagine any
extra options exported to java will do the trick failing this test.

#1061059#10
Date:
2024-01-17 15:34:48 UTC
From:
To:
With a little less 'cutting' it seems to work, but I tested it only
against openjdk 8, 11 and 17. I didn't understand the need of the first
call of "cut -d'-' -f1" anyways.
--- javaws_orig.sh 2024-01-17 16:25:24.601970808 +0100 +++ javaws.sh 2024-01-17 16:25:57.982161672 +0100 @@ -97,9 +97,9 @@ # Support Modular JDK (jigsaw): MODULAR_JDK="NO" fullversion=`${JAVA} -version 2>&1` -version=`echo $fullversion | head -n 1 | cut -d'-' -f1 | cut -d'"' -f2 | cut -d'.' -f1` +version=`echo $fullversion | head -n 1 | cut -d'"' -f2 | cut -d'.' -f1` if [ "$version" -eq "1" ]; then - version=`echo $fullversion | head -n 1 | cut -d'-' -f1 | cut -d'"' -f2 | cut -d'.' -f2` + version=`echo $fullversion | head -n 1 | cut -d'"' -f2 | cut -d'.' -f2` fi if [ "$version" -ge "9" ]; then MODULAR_JDK="YES"