Last active
September 26, 2017 20:00
-
-
Save colinbowern/9db0945f10adde26148e0d5e78596500 to your computer and use it in GitHub Desktop.
Install Oracle JDK 9 from 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 | |
# Download from Oracle's site - sadly no https. | |
wget --no-cookies --timestamping --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/9+181/jdk-9_linux-x64_bin.tar.gz --directory /tmp | |
# Decompress package into /opt/java | |
if [ ! -d "/opt/java" ]; then | |
mkdir /opt/java | |
fi | |
tar zxvf /tmp/jdk-9_linux-x64_bin.tar.gz --directory /opt/java | |
# Update path references in system profile and make it default | |
echo 'export JAVA_HOME=/opt/java/jdk-9' > /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/jdk-9/bin/java" 1 | |
sudo update-alternatives --install "/usr/bin/javac" "javac" "/opt/java/jdk-9/bin/javac" 1 | |
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/opt/java/jdk-9/bin/javaws" 1 | |
sudo update-alternatives --set java /opt/java/jdk-9/bin/java | |
sudo update-alternatives --set javac /opt/java/jdk-9/bin/javac | |
sudo update-alternatives --set javaws /opt/java/jdk-9/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