pink cylinders

More than Four

...there's an axis for that.

Installing Oracle's JDK in Ubuntu Linux

Just for my own notes, because I can never remember this stuff.

1. Check the architecture of your host:

colin@Mongpy:~$ uname -m
x86_64

2. Grab the appropriate download from Oracle's web site:

image

My web browser puts it in the Downloads folder under home.

colin@Mongpy:~$ ls -l ~/Downloads
total 393356
drwxr-sr-x 7 colin colin 4096 Mar 31 12:21 eclipse-installer
-rw-rw-r-- 1 colin colin 185540433 May 25 13:19 jdk-8u131-linux-x64.tar.gz
-rw-rw-r-- 1 colin colin 21944320 Mar 29 14:18 mysql-workbench-community-6.3.9-1ubuntu16.10-amd64.deb
-rw-rw-r-- 1 colin colin 195297254 May 25 12:47 pycharm-community-2017.1.3.tar.gz

3. Open a terminal and get superuser access:

colin@Mongpy:~$ sudo su
[sudo] password for colin:
root@Mongpy:/home/colin#

4. Make a directory and expand the archive:

root@Mongpy:/home/colin# mkdir /opt/jdk
root@Mongpy:/home/colin# tar -zxf ./Downloads/jdk-8u131-linux-x64.tar.gz -C /opt/jdk
root@Mongpy:/home/colin# ls -l /opt/jdk
total 4
drwxr-xr-x 8 uucp 143 4096 Mar 15 01:35 jdk1.8.0_131

5. Review the current default JDK:

root@Mongpy:~# update-alternatives --display java
java - auto mode
link best version is /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
link currently points to /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
link java is /usr/bin/java
slave java.1.gz is /usr/share/man/man1/java.1.gz
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - priority 1081
slave java.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz

root@Mongpy:~# update-alternatives --display javac
javac - auto mode
link best version is /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
link currently points to /usr/lib/jvm/java-8-openjdk-amd64/bin/javac
link javac is /usr/bin/javac
slave javac.1.gz is /usr/share/man/man1/javac.1.gz
/usr/lib/jvm/java-8-openjdk-amd64/bin/javac - priority 1081
slave javac.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/man/man1/javac.1.gz

Note the current "priority" is 1081.

6. Set the Oracle version as the default JDK, using a higher priority, say 1090:

root@Mongpy:/home/colin# update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_131/bin/java 1090

update-alternatives: using /opt/jdk/jdk1.8.0_131/bin/java to provide /usr/bin/java (java) in auto mode

root@Mongpy:/home/colin# update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_131/bin/javac 1090

update-alternatives: using /opt/jdk/jdk1.8.0_131/bin/javac to provide /usr/bin/javac (javac) in auto mode

root@Mongpy:/home/colin# update-alternatives --display java
java - auto mode
link best version is /opt/jdk/jdk1.8.0_131/bin/java
link currently points to /opt/jdk/jdk1.8.0_131/bin/java
link java is /usr/bin/java
slave java.1.gz is /usr/share/man/man1/java.1.gz
/opt/jdk/jdk1.8.0_131/bin/java - priority 1090
/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java - priority 1081
slave java.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/jre/man/man1/java.1.gz

root@Mongpy:/home/colin# update-alternatives --display javac
javac - auto mode
link best version is /opt/jdk/jdk1.8.0_131/bin/javac
link currently points to /opt/jdk/jdk1.8.0_131/bin/javac
link javac is /usr/bin/javac
slave javac.1.gz is /usr/share/man/man1/javac.1.gz
/opt/jdk/jdk1.8.0_131/bin/javac - priority 1090
/usr/lib/jvm/java-8-openjdk-amd64/bin/javac - priority 1081
slave javac.1.gz: /usr/lib/jvm/java-8-openjdk-amd64/man/man1/javac.1.gz

7. Finally, testing:

colin@Mongpy:~$ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

Cool.

Add comment

Loading