There are several posts on installing Oracle 8 with PPAs, but I need to have more control when installing my development environment. I used a good WikiHow Article when I installed Oracle Java 7, but I didn’t find a comparable upgrade guide for Java 8. So I created this Upgrade Guide for Java 8, using the WhikiHow Article as a starting point. I used this approach successfully on 3 different Ubuntu and Linux Mint PCs. All are 64x machines which is the version of Oracle Java 8 we’ll be using in this walk-through.
At the end of the guide is a bash script you can download which may speed-up your upgrade, particularly if you have several Linux machines like me.
First let’s confirm what we’ll download from Oracle’s Java 8 Downloads Page, which is the Java SE 8 JDK and JRE circled below.
Once downloaded into our Downloads directory, the tar.gz’s look like this.
Time to break out the terminal prompt.
Update the Java Path in /etc/profile
Logically we can do this later, but to conform to the order of the bash script we’re going to upgrade the Java Path in /etc/profile and get it out of the way. Here is the section we’ll be upgrading in /etc/profile.
Copy the tar.gz’s to /usr/local/java
Out of gedit and Back to the terminal prompt.
sudo -s cp -r jdk-8-linux-x64.tar.gz /usr/local/java
sudo -s cp -r jre-8-linux-x64.tar.gz /usr/local/java
Unpack the Binaries
We next want to unpack our new Oracle 1.8 Java binaries in the directory /usr/local/java.
sudo tar xvzf jdk-8-linux-x64.tar.gz
sudo tar xvzf jre-8-linux-x64.tar.gz
When we unpack the binaries our /usr/local/java directory will look something like this.
Configure Java 8 for our Ubuntu System
Next we’ll inform the system where our Java 8 JRE and JDK are located.
sudo update-alternatives --install "/usr/bin/java" \
"java" "/usr/local/java/jre1.8.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" \
"javac" "/usr/local/java/jdk1.8.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" \
"javaws" "/usr/local/java/jre1.8.0/bin/javaws" 1
Then inform our Linux system that Oracle Java JRE 1.8.0 is the new default Java.
sudo update-alternatives --set java /usr/local/java/jre1.8.0/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk1.8.0/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jre1.8.0/bin/javaws
Update the Path
We update the path by reloading /etc/profile.
Our real payoff will be using Java 8 in Eclipse, but that comes later. For now we’ll enjoy seeing what is returned when we display our current Java Version.
Oh, I almost forgot the bash script which performs the upgrade. Here it is. You’re completely on your own with it, of course, and may have to change some file names depending on your system. It is also an UPGRADE script, and assumes Oracle 1.7 is installed and your current default JDK/JRE.