Skip to content

Instantly share code, notes, and snippets.

@rafaellucio
Last active August 29, 2015 14:03
Show Gist options
  • Save rafaellucio/29f1f04ca0b497a42309 to your computer and use it in GitHub Desktop.
Save rafaellucio/29f1f04ca0b497a42309 to your computer and use it in GitHub Desktop.
Install Oracle Java on a Debian

###How To Manually Install Oracle Java on a Debian or Ubuntu VPS

wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u5-b13/jdk-8u5-linux-x64.tar.gz

  • Create a directory for your JDK installation:

mkdir /opt/jdk

  • and extract java into the /opt/jdk directory:

tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk

  • Verify that the file has been extracted into the /opt/jdk directory.

ls /opt/jdk

####Setting Oracle JDK as the default JVM

  • To set it as the default JVM in your machine run:

update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_05/bin/java 1062

and

update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_05/bin/javac 1062

####Verify your installation

  • Verify that java has been successfully configured by running:

update-alternatives --display java

######The output should look like this:

java - auto mode link currently points to /opt/jdk/jdk1.8.0_05/bin/java /opt/jdk/jdk1.8.0_05/bin/java - priority 100 Current 'best' version is '/opt/jdk/jdk1.8.0_05/bin/java'

  • Javac

update-alternatives --display javac

######The output should look like this:

javac - auto mode link currently points to /opt/jdk/jdk1.8.0_05/bin/javac /opt/jdk/jdk1.8.0_05/bin/javac - priority 100 Current 'best' version is '/opt/jdk/jdk1.8.0_05/bin/javac'

  • Another easy way to check your installation is:

java -version

######Output

java version "1.8.0_05" Java(TM) SE Runtime Environment (build 1.8.0_05-b13)

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