Skip to content

Instantly share code, notes, and snippets.

@Auronmatrix
Created May 22, 2019 12:05
Show Gist options
  • Save Auronmatrix/9c9b99e4a7b458ddaec24eb29fe96140 to your computer and use it in GitHub Desktop.
Save Auronmatrix/9c9b99e4a7b458ddaec24eb29fe96140 to your computer and use it in GitHub Desktop.
# Must be run as sudo
# Install Java 1.8
## Download Java tar and extract
cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz"
tar xzf jdk-8u201-linux-x64.tar.gz
## Configure alternatives
cd jdk1.8.0_201/
alternatives --install /usr/bin/java java /opt/jdk1.8.0_201/bin/java 2
alternatives --config java
alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_201/bin/jar 2
alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_201/bin/javac 2
alternatives --set jar /opt/jdk1.8.0_201/bin/jar
alternatives --set javac /opt/jdk1.8.0_201/bin/javac
java -version
## Set ENV Vars
export JAVA_HOME=/opt/jdk1.8.0_201
export JRE_HOME=/opt/jdk1.8.0_201/jre
export PATH=$PATH:/opt/jdk1.8.0_201/bin:/opt/jdk1.8.0_201/jre/bin
## Add ENV VARS to /etc/environment so they are persisted
cat /etc/environment
echo '------------'
cat <<EOF >> /etc/environment
JAVA_HOME=/opt/jdk1.8.0_201
JRE_HOME=/opt/jdk1.8.0_201/jre
PATH=$PATH:/opt/jdk1.8.0_201/bin:/opt/jdk1.8.0_201/jre/bin
EOF
echo '-----------'
cat /etc/environment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment