I wrote a bash script to download a specific java binary tar ball, untar it, and then configure the java version Since the java install tool requires manual interaction I'm using "expect" to "send" the answer to the command. I put the java binaries into "/opt"
curl -o /opt/jdk-8u201.tar.gz https://hostname
tar -zxvf /opt/jdk-8u201.tar.gz -C /opt
#!/bin/bash
yum -y install expect
EXPECT=$(which expect)
JAVA_HOME=/opt/jdk-8u201
update-alternatives --install /usr/bin/java java ${JAVA_HOME%/}/bin/java 2000
${EXPECT} <<EOD
spawn update-alternatives --config java
expect "Enter to keep the current selection\[\+\], or type selection number:"
send 3
EOD
When I perform the installation manually and enter:
echo $JAVA_PATH
it prints the information.
If I do it in a shell script, it does not update the path.
Is there something I don't see? Thank you
Cheers, Roland