y0n1
6/6/2016 - 10:24 AM

Automated installation of Oracle JDK8 update 92 for Ubuntu 14.04 [UNTESTED]

Automated installation of Oracle JDK8 update 92 for Ubuntu 14.04 [UNTESTED]

#! /bin/bash

cd ~

# Purge OpenJDK/JRE
sudo apt-get purge openjdk-\*

# Create installation folder
sudo mkdir -p /usr/local/java

# Download JDK8
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u92-b14/jdk-8u92-linux-x64.tar.gz
 
# Put the compressed file inside the installation folder
sudo mv jdk-8u92-linux-x64.tar.gz /usr/local/java/
 
cd /usr/local/java/
 
# Unpack the compressed Java binaries, in the directory /usr/local/java
sudo tar xvzf jdk-8u92-linux-x64.tar.gz
 
# Create environment variables
sudo (echo "JAVA_HOME=/usr/local/java/jdk1.8.0_92" >> /etc/profile) 
sudo (echo "JRE_HOME=$JAVA_HOME/jre" >> /etc/profile)
sudo (echo "PATH=$PATH:$JRE_HOME/bin:$JAVA_HOME/bin" >> /etc/profile)
sudo (echo "export JAVA_HOME" >> /etc/profile)
sudo (echo "export JRE_HOME" >> /etc/profile)
sudo (echo "export PATH" >> /etc/profile)

# Update the system so it is able to find the binaries
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_92/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_92/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk1.8.0_92/bin/javaws" 1

# Set Oracle JDK/JRE as default 
sudo update-alternatives --set java /usr/local/java/jdk1.8.0_92/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.8.0_92/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jdk1.8.0_92/bin/javaws

. /etc/profle