John Bokma MexIT
freelance Perl programmer

Manual installation of Oracle Java JDK on Ubuntu

Friday, June 24, 2011 | 1 comment

In the evening I installed the Oracle Java JDK on Ubuntu Lucid Lynx. Since Oracle Java is no longer available via the default repositories I decided to manually install Java instead of adding a repository and possibly installing an older version. Since I need Java to run programs like Apache Ant, Apache FOP, and Saxon for my work as a freelance Perl programmer I prefer to use the Oracle Java over OpenJDK even though the latter might be a solid alternative for my purposes.

Downloading the Oracle Java JDK

In order to download the Standard Edition (SE) of the Oracle Java JDK first I clicked on the red "Download" button under the JDK heading on the Java SE Downloads page. This opened another page in my browser with a table of files with above it a "Accept License Agreement" box. I clicked the radio button in front of "Accept" and clicked the now bold jdk-6u26-linux-i586.bin link after "Linux x86 - Self Extracting Installer" entry in the table.

Installing the JDK

When the download had finished I moved the downloaded file to /usr/local/java, made it executable, ran it, and deleted it as follows:

sudo mkdir -p /usr/local/java
sudo mv /home/john/Downloads/jdk-6u26-linux-x64.bin /usr/local/java
cd /usr/local/java
sudo chmod 700 jdk-6u26-linux-x64.bin
sudo ./jdk-6u26-linux-x64.bin
sudo rm jdk-6u26-linux-x64.bin
sudo ln -s jdk1.6.0_26 /usr/local/java/latest

The installer tried to open a browser window. However, this failed, I guess because of Firefox running as a normal user.

Now, with the Java SE Development Kit 6 update 26 installed I only needed to add two variables to /etc/environment and extend the PATH variable. Notice that in the previous step I created a symbolic link named latest. When a newer JDK version comes out I only have to update this symbolic link since I refer to latest in /etc/environemnt:


I used sudo vi /etc/environment and changed the file until it was equal to the above four lines. Make sure that nothing follows after the backslash except a newline. If you put accidentally a space after the backslash you might not be able to login later on. Also note that variable interpolation as used in shell scripts does not work.

I made that mistake and ended up with no longer being able to login. This was easy fixed by booting from a live CD and editing /etc/enviroment.

If you don't want to log out and log back in to have the updated /etc/environment read in just type:

source /etc/environment

After this you should be able to verify the version of both the java and javac program:

java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
javac -version
javac 1.6.0_26

Important: installing OpenJDK at a later stage along with Oracle Java JDK might result in hard to track issues.

Also today

Please post a comment | read 1 comment by GlynnR | RSS feed