X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=blobdiff_plain;f=shell%2Fupdate-java-alternatives.sh;h=0bed1ec2117111cddfdc2f06a4d410e90046873c;hb=refs%2Ftags%2Fv0.78.0;hp=69bf0195fc3aa02bcfcc1f856380ba175447a4fa;hpb=00abd5048e7fa6b55c2ccda441a8c7e72cd2d48d;p=releng%2Fglobal-jjb.git diff --git a/shell/update-java-alternatives.sh b/shell/update-java-alternatives.sh index 69bf0195..0bed1ec2 100644 --- a/shell/update-java-alternatives.sh +++ b/shell/update-java-alternatives.sh @@ -8,16 +8,19 @@ # which accompanies this distribution, and is available at # http://www.eclipse.org/legal/epl-v10.html ############################################################################## - +echo "---> update-java-alternatives.sh" # This script takes the java-version variable to set the proper alternative # for java, javac and java_sdk_openjdk for ubuntu or centos/fedora/redhat distros JAVA_ENV_FILE="/tmp/java.env" update-java-redhat() { - if [[ "${SET_JDK_VERSION//[a-zA-Z]/}" = "11" ]]; then - export JAVA_HOME="/usr/lib/jvm/java-11-openjdk" + JAVA_RELEASE=${SET_JDK_VERSION//[a-zA-Z]/} + if [[ ${JAVA_RELEASE} -ge 9 ]]; then + # Java 9 or newer: new version format + export JAVA_HOME="/usr/lib/jvm/java-${JAVA_RELEASE}-openjdk" else + # Java 8 or older: old version format export JAVA_HOME="/usr/lib/jvm/java-1.${SET_JDK_VERSION//[a-zA-Z:-]/}.0-openjdk" fi sudo /usr/sbin/alternatives --install /usr/bin/java java "${JAVA_HOME}/bin/java" 1