Created
September 26, 2017 20:53
-
-
Save colinbowern/44f0542900c7d39fdaac6b7c5d17993a to your computer and use it in GitHub Desktop.
Install Oracle JDK 8 using the command line on Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
URL=http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz | |
FILE=jdk-8u144-linux-x64.tar.gz | |
ROOT=jdk1.8.0_144 | |
# Download from Oracle's site - sadly no https. | |
wget --no-cookies --timestamping --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" $URL --directory /tmp | |
# Decompress package into /opt/java | |
if [ ! -d "/opt/java" ]; then | |
mkdir /opt/java | |
fi | |
tar zxvf /tmp/$FILE --directory /opt/java | |
# Update path references in system profile and make it default | |
echo 'export JAVA_HOME=/opt/java/'$ROOT > /etc/profile.d/jdk.sh | |
echo 'export PATH=$PATH:$HOME/bin:$JAVA_HOME/bin' >> /etc/profile.d/jdk.sh | |
chmod +x /etc/profile.d/jdk.sh | |
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/$ROOT/bin/java" 1 | |
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/$ROOT/bin/javac" 1 | |
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/java/$ROOT/bin/javaws" 1 | |
sudo update-alternatives --set java /opt/java/$ROOT/bin/java | |
sudo update-alternatives --set javac /opt/java/$ROOT/bin/javac | |
sudo update-alternatives --set javaws /opt/java/$ROOT/bin/javaws | |
# Reload system profile | |
. /etc/profile | |
java -version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
fail