Fix how Java 8 or 11 version is selected

Change-Id: I6bacdc5dec0c8dec3549fa221dae8ec09c52a2f7
diff --git a/jjb/onos/onos-release-build-verify.sh b/jjb/onos/onos-release-build-verify.sh
index 22898b2..4169af0 100644
--- a/jjb/onos/onos-release-build-verify.sh
+++ b/jjb/onos/onos-release-build-verify.sh
@@ -13,8 +13,7 @@
 if [ ${GERRIT_BRANCH} == "master" -o ${GERRIT_BRANCH} == "onos-2.2" ]
 then
     echo Installing OPEN JDK 11
-    sudo update-alternatives --set java  /usr/lib/jvm/java-11-amazon-corretto/bin/java
-    sudo update-alternatives --set javac /usr/lib/jvm/java-11-amazon-corretto/bin/javac
+    sudo update-java-alternatives -s java-11-amazon-corretto
     java -version
 else
     echo Using default JDK
diff --git a/jjb/onos/onos-release-build.sh b/jjb/onos/onos-release-build.sh
index 77d48e4..0fe572a 100644
--- a/jjb/onos/onos-release-build.sh
+++ b/jjb/onos/onos-release-build.sh
@@ -13,8 +13,7 @@
 if [ ${GERRIT_BRANCH} == "master" -o ${GERRIT_BRANCH} == "onos-2.2" ]
 then
     echo Installing OPEN JDK 11
-    sudo update-alternatives --set java  /usr/lib/jvm/java-11-amazon-corretto/bin/java
-    sudo update-alternatives --set javac /usr/lib/jvm/java-11-amazon-corretto/bin/javac
+    sudo update-java-alternatives -s java-11-amazon-corretto
     java -version
 else
     echo Using default JDK
diff --git a/packer/provision/baseline.sh b/packer/provision/baseline.sh
index 532247c..cf0f3c6 100644
--- a/packer/provision/baseline.sh
+++ b/packer/provision/baseline.sh
@@ -246,13 +246,54 @@
     echo "$CORRETTO_JAVA11_SHA256SUM  /tmp/corretto_java11.deb" | sha256sum -c -
     dpkg -i /tmp/corretto_java11.deb
 
+    # Fix corretto 11 lack of jinfo that prevents update-java-alternatives from working
+    # Upstream fix not integrated yet: https://github.com/corretto/corretto-11/pull/27
+    cat <<EOF >/usr/lib/jvm/.java-11-amazon-corretto.jinfo
+name=java-11-amazon-corretto
+alias=java-11-amazon-corretto
+priority=11100002
+section=main
+
+jdk java /usr/lib/jvm/java-11-amazon-corretto/bin/java
+jdk keytool /usr/lib/jvm/java-11-amazon-corretto/bin/keytool
+jdk rmid /usr/lib/jvm/java-11-amazon-corretto/bin/rmid
+jdk rmiregistry /usr/lib/jvm/java-11-amazon-corretto/bin/rmiregistry
+jdk jjs /usr/lib/jvm/java-11-amazon-corretto/bin/jjs
+jdk pack200 /usr/lib/jvm/java-11-amazon-corretto/bin/pack200
+jdk unpack200 /usr/lib/jvm/java-11-amazon-corretto/bin/unpack200
+jdk javac /usr/lib/jvm/java-11-amazon-corretto/bin/javac
+jdk jaotc /usr/lib/jvm/java-11-amazon-corretto/bin/jaotc
+jdk jlink /usr/lib/jvm/java-11-amazon-corretto/bin/jlink
+jdk jmod /usr/lib/jvm/java-11-amazon-corretto/bin/jmod
+jdk jhsdb /usr/lib/jvm/java-11-amazon-corretto/bin/jhsdb
+jdk jar /usr/lib/jvm/java-11-amazon-corretto/bin/jar
+jdk jarsigner /usr/lib/jvm/java-11-amazon-corretto/bin/jarsigner
+jdk javadoc /usr/lib/jvm/java-11-amazon-corretto/bin/javadoc
+jdk javap /usr/lib/jvm/java-11-amazon-corretto/bin/javap
+jdk jcmd /usr/lib/jvm/java-11-amazon-corretto/bin/jcmd
+jdk jconsole /usr/lib/jvm/java-11-amazon-corretto/bin/jconsole
+jdk jdb /usr/lib/jvm/java-11-amazon-corretto/bin/jdb
+jdk jdeps /usr/lib/jvm/java-11-amazon-corretto/bin/jdeps
+jdk jdeprscan /usr/lib/jvm/java-11-amazon-corretto/bin/jdeprscan
+jdk jimage /usr/lib/jvm/java-11-amazon-corretto/bin/jimage
+jdk jinfo /usr/lib/jvm/java-11-amazon-corretto/bin/jinfo
+jdk jmap /usr/lib/jvm/java-11-amazon-corretto/bin/jmap
+jdk jps /usr/lib/jvm/java-11-amazon-corretto/bin/jps
+jdk jrunscript /usr/lib/jvm/java-11-amazon-corretto/bin/jrunscript
+jdk jshell /usr/lib/jvm/java-11-amazon-corretto/bin/jshell
+jdk jstack /usr/lib/jvm/java-11-amazon-corretto/bin/jstack
+jdk jstat /usr/lib/jvm/java-11-amazon-corretto/bin/jstat
+jdk jstatd /usr/lib/jvm/java-11-amazon-corretto/bin/jstatd
+jdk rmic /usr/lib/jvm/java-11-amazon-corretto/bin/rmic
+jdk serialver /usr/lib/jvm/java-11-amazon-corretto/bin/serialver
+
+EOF
+
     # Set default version to be Java8
-    update-alternatives --set java  /usr/lib/jvm/java-1.8.0-amazon-corretto/jre/bin/java
-    update-alternatives --set javac /usr/lib/jvm/java-1.8.0-amazon-corretto/bin/javac
+    update-java-alternatives --set java-1.8.0-amazon-corretto
 
     # Set default version to be Java11
-    # update-alternatives --set java  /usr/lib/jvm/java-11-amazon-corretto/bin/java
-    # update-alternatives --set javac /usr/lib/jvm/java-11-amazon-corretto/bin/javac
+    # update-java-alternatives -s java-11-amazon-corretto
 
     ########################
     # --- START LFTOOLS DEPS