I am trying to install java 11 on oracle linux 9. using the below script for instalation.
#! /bin/bash
java_version=11.0.22.7.1
# Linux
os_arch=$(uname -s); os_arch_lower=$(echo "$os_arch" | tr '[:upper:]' '[:lower:]'); echo "$os_arch_lower"
# architecture x86
os_arch=$(uname -i | cut -d'_' -f1 | tr '[:upper:]' '[:lower:]'); echo "$os_arch"
# Create the destination directory if it does not exist
mkdir -p /usr/java/
# Install Amazon correto jdk 11
curl -LO https://corretto.aws/downloads/resources/${java_version}/amazon-corretto-${java_version}-${os_arch_lower}-${os_arch}.tar.gz
&& mv "amazon-corretto-${java_version}-${os_arch_lower}-${os_arch}.tar.gz" "/usr/java/amazon-corretto-${java_version}-${os_arch_lower}-${os_arch}.tar.gz"
&& cd /usr/java
&& tar zxvf "amazon-corretto-${java_version}-${os_arch_lower}-${os_arch}.tar.gz"
&& JAVA_HOME=/usr/java/amazon-corretto-${java_version}-${os_arch_lower}-${os_arch}
&& export JAVA_HOME=/usr/java/amazon-corretto-${java_version}-${os_arch_lower}-${os_arch}
&& export PATH=$JAVA_HOME/bin:$PATH
&& echo $PATH
&& java --version
even though after untarring the files to /usr/java/
i am getting error while running java command which means some issue with java installation.
bash.sh: line 23: /usr/java/amazon-corretto-11.0.22.7.1-linux-x86/bin/java: No such file or directory
please help me. what am i missing?
https://github.com/devwithkrishna/create-jenkins-docker-image/blob/main/download_install_amazon_correto.sh
i have tried to fix issue myself and with available solutions from google. but none of them worked.
even though it says it didnt find java file on error:
/usr/java/amazon-corretto-11.0.22.7.1-linux-x86/bin/java: No such file or directory
The file is present.
[root@83f38c9b634e /]# ls -la /usr/java/amazon-corretto-11.0.22.7.1-linux-x86/bin/java
-rwxr-xr-x 1 root root 7436 Jan 10 19:48 /usr/java/amazon-corretto-11.0.22.7.1-linux-x86/bin/java