Skip to content

Instantly share code, notes, and snippets.

@rjurney
Created July 15, 2014 23:54
Show Gist options
  • Save rjurney/7c855a0afa48777755d2 to your computer and use it in GitHub Desktop.
Save rjurney/7c855a0afa48777755d2 to your computer and use it in GitHub Desktop.
How to automagically install Oracle JDK 1.8 on CentOS
# Install Java 1.8 in CentOS/RHEL 6.X
sudo yum remove -y java-1.6.0-openjdk
wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-linux-x64.rpm" \
-O jdk-8-linux-x64.rpm
sudo rpm -Uvh jdk-8-linux-x64.rpm
sudo alternatives --install /usr/bin/java java /usr/java/jdk1.8.0/jre/bin/java 20000
sudo alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0/bin/jar 20000
sudo alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0/bin/javac 20000
sudo alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.8.0/jre/bin/javaws 20000
sudo alternatives --set java /usr/java/jdk1.8.0/jre/bin/java
sudo alternatives --set javaws /usr/java/jdk1.8.0/jre/bin/javaws
sudo alternatives --set javac /usr/java/jdk1.8.0/bin/javac
sudo alternatives --set jar /usr/java/jdk1.8.0/bin/jar
@mtutty
Copy link

mtutty commented Jul 17, 2015

Or, there's no reason to eliminate the OpenJDK when you have, erm, alternatives...

wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8-b132/jdk-8-linux-x64.rpm" \
-O jdk-8-linux-x64.rpm
sudo rpm -Uvh jdk-8-linux-x64.rpm
sudo alternatives --install /usr/bin/java java /usr/java/jdk1.8.0/jre/bin/java 20000
sudo alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0/bin/jar 20000
sudo alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0/bin/javac 20000
sudo alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.8.0/jre/bin/javaws 20000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment