Skip to content

Instantly share code, notes, and snippets.

@skanjo
Last active February 2, 2016 04:23
Show Gist options
  • Save skanjo/ab2da8ceec99791ced50 to your computer and use it in GitHub Desktop.
Save skanjo/ab2da8ceec99791ced50 to your computer and use it in GitHub Desktop.
Install Oracle Java on Ubuntu 14.04

Get Oracle java tarball

cd ~
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/8u71-b15/jdk-8u71-linux-x64.tar.gz"

Make install directory

sudo mkdir /opt/jdk

Install

sudo tar -zxf /home/skanjo/jdk-8u71-linux-x64.tar.gz -C /opt/jdk

Verify

ls /opt/jdk

Check current java, should be none

java -version

Set system java and javac

update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_71/bin/java 100
update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_71/bin/javac 100

Verify alternatives

update-alternatives --display java
update-alternatives --display javac

Verify on system path

java -version

To update java, download new tarball and install in opt/jdk

update-alternatives --install /usr/bin/java java /opt/jdk/jdk.new.version/bin/java 110
update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk.new.version/bin/javac 110

Optionally remove old jdk

update-alternatives --remove java /opt/jdk/jdk.old.version/bin/java
update-alternatives --remove javac /opt/jdk/jdk.old.version/bin/javac
rm -rf /opt/jdk/jdk.old.version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment