Skip to content

Instantly share code, notes, and snippets.

@thyn
Last active November 22, 2018 10:14
Show Gist options
  • Save thyn/85e834101ab86ebe750347c531fe9b1c to your computer and use it in GitHub Desktop.
Save thyn/85e834101ab86ebe750347c531fe9b1c to your computer and use it in GitHub Desktop.
java
#!/bin/sh
JAVA_VER=jdk-9.0.4
JAVA_FILE=jdk-9.0.4_linux-x64_bin.tar.gz
cd /opt/
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.tar.gz"
tar xzf $JAVA_FILE
rm -rf $JAVA_FILE
cd "/opt/${JAVA_VER}/"
alternatives --install /usr/bin/java java "/opt/${JAVA_VER}/bin/java" 1
alternatives --install /usr/bin/javac javac "/opt/${JAVA_VER}/bin/javac" 1
alternatives --install /usr/bin/jar jar "/opt/${JAVA_VER}/bin/jar" 1
alternatives --set java "/opt/${JAVA_VER}/bin/java"
alternatives --set jar "/opt/${JAVA_VER}/bin/jar"
alternatives --set javac "/opt/${JAVA_VER}/bin/javac"
java -version
#!/bin/sh
JAVA_VER=jdk1.8.0_191
JAVA_FILE=jdk-8u191-linux-x64.tar.gz?AuthParam=1542881649_4438c73a0f8d2543268e927684c7c2d6
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/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz?AuthParam=1542881649_4438c73a0f8d2543268e927684c7c2d6"
tar xzf $JAVA_FILE
rm -rf $JAVA_FILE
cd "/opt/${JAVA_VER}/"
alternatives --install /usr/bin/java java "/opt/${JAVA_VER}/bin/java" 1
alternatives --install /usr/bin/javac javac "/opt/${JAVA_VER}/bin/javac" 1
alternatives --install /usr/bin/jar jar "/opt/${JAVA_VER}/bin/jar" 1
alternatives --set java "/opt/${JAVA_VER}/bin/java"
alternatives --set jar "/opt/${JAVA_VER}/bin/jar"
alternatives --set javac "/opt/${JAVA_VER}/bin/javac"
java -version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment