Down-Rev Oracle JDK/JRE 8 to JDK/JRE 7 on Ubuntu 14.04

Today, I installed the PhpStorm-8 upgrade and immediately noticed a lot of problems in the UI.  Most notable of which being that none of the bottom toolbars were clickable.  Including the "Git" button for source-code control.

Additionally, when I clicked on the menu option: VCS -> GIT -> BRANCHES, I got no result in the UI - no pop-up, no new window... nothing.

I filed an issue with JetBrains who responded almost immediately - the latest version of PhpStorm has issues with the Oracle JDK version 8 and their recommendation was to down-rev to Version 7.

I upgraded my JDK to version 8 last month from this blog post - and all went very well.  Unfortunately, the author of the post didn't include uninstall instructions to back-out the JDK and JREs.

This blog postlet will enumerate the steps for backing-out Oracle's JDK 8 and re-installing JDK (and JRE) Version 7.


My installation, since I followed the wiki-how article, is located in /usr/local/java:

mshallop@pamcakes:/usr/local/java$ ls -l
total 218412
drwxr-xr-x 8 mshallop mshallop      4096 Jul 30 13:25 jdk1.8.0_20
-rw-rw-r-- 1 mshallop mshallop 160872342 Aug 26 09:46 jdk-8u20-linux-x64.tar.gz
drwxr-xr-x 6 uucp          143      4096 Jul 30 13:22 jre1.8.0_20
-rw-rw-r-- 1 mshallop mshallop  62751094 Aug 26 09:58 jre-8u20-linux-x64.tar.gz

To remove the JDK, and JRE, we're going to use the update-alternatives command, reversing the installation directives.  Check your local installation to verify the location of your JDK.  In my case, I installed version 8 in /usr/local/java:

$ sudo update-alternatives --remove "java" "/usr/local/java/jdk1.8.0_20/bin/java"
$ sudo update-alternatives --remove "javac" "/usr/local/java/jdk1.8.0_20/bin/javac"
$ sudo update-alternatives --remove "javaws" "/usr/local/java/jdk1.8.0_20/bin/javaws"

You'll get a message relative to the remove operation that looks like this:

update-alternatives: removing manually selected alternative - switching java to auto mode

Next, nuke (delete) the installation files:

$ sudo rm -r /usr/local/java

On my development laptop, I had already installed the Oracle JDK 7 and JRE 7, version 1.7.0_45.   I checked the Oracle site for JDK 7 and saw that the packages have been updated to 1.7.0_67 so I downloaded the updated JDK and installed it to my /usr/lib/jvm directory.


If you need to download the oracle JDK, I'd recommend the following:

$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java7-installer

I keep a soft-link from the directory "java-1.7.0" to the current/latest JDK and JRE.  I've found it expedient to maintain the current+last versions of packages for times, like these, when I need to revert or down-rev because of compatibility problems.

Repeat the process for the JRE so that your directory looks similar to the following:

mshallop@pamcakes:/usr/lib/jvm$ ls -l
total 12
lrwxrwxrwx 1 root     root       12 Sep 16 11:36 java-1.7.0 -> jdk1.7.0_67/
drwxr-xr-x 8 uucp          143 4096 Sep 16 11:35 jdk1.7.0_45
drwxr-xr-x 8 mshallop mshallop 4096 Jul 25 09:51 jdk1.7.0_67
lrwxrwxrwx 1 root     root       12 Sep 16 11:44 jre-1.7.0 -> jre1.7.0_67/
drwxr-xr-x 6 mshallop mshallop 4096 Jul 25 09:46 jre1.7.0_67

Next, use the update-alternatives command to tell Ubuntu where the java commands are located:

$ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-1.7.0/bin/java" 1
update-alternatives: using /usr/lib/jvm/java-1.7.0/bin/java to provide /usr/bin/java (java) in auto mode
$ sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java-1.7.0/bin/javac" 1
update-alternatives: using /usr/lib/jvm/java-1.7.0/bin/javac to provide /usr/bin/javac (javac) in auto mode
$ sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/java-1.7.0/bin/javaws" 1
update-alternatives: using /usr/lib/jvm/java-1.7.0/bin/javaws to provide /usr/bin/javaws (javaws) in auto mode

Execute these three commands which directs Ubuntu to set the run-time environment, compiler, and web-start, respectively:

$ sudo update-alternatives --set java /usr/lib/jvm/java-1.7.0/bin/java
$ sudo update-alternatives --set javac /usr/lib/jvm/java-1.7.0/bin/javac
$ sudo update-alternatives --set javaws /usr/lib/jvm/java-1.7.0/bin/javaws

Using your editor of choice (koff: vi), update /etc/profile to (replace) add the PATH directives for the new JDK environment:

export JAVA_HOME=/usr/lib/jvm/java-1.7.0
export PATH=$PATH:/usr/lib/jvm/java-1.7.0/bin

Reload /etc/profile into your current environment and check to validate that your java version was down-rev'd successfully:

$ source /etc/profile
$ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
$ javac -version
javac 1.7.0_67

I fired-up my new copy of PhpStorm8 and everything appears to be working as expected.