Install the latest Java 7 JDK on Ubuntu Linux Server 10.04 without apt-get

I was trying to set up Apache Tomcat on an older server running Ubuntu 10.04 and noticed that Java wasn’t actually installed by default. Also, the licensing agreement with Oracle seems to have changed and it is no longer possible to just use apt-get to install it. You have to manually accept the licensing agreement so even “wget” wont work any more (you just get a “download-fail-XXXXXXX.html” file instead.

First up, you have to go to the Java JDK download page and manually accept the licensing agreement. This must be done from a PC with a UI and a browser so no “wget”. You need to get the correct version, which in my case was the x86 tar.gz version. When this is downloaded you should have a “jdk-7u9-linux-i586.tar.gz” file which then needs to be copied to your Ubuntu server (I copied to my user’s home directory).

Now you have the file on your Ubuntu server you can extract it using:

tar -xvf jdk-7u9-linux-i586.tar.gz

This should give you a directory “jdk1.7.0_09″ which we need to move to somewhere sensible such as “/usr/lib/jvm/jdk1.7.0_09″:

sudo mv jdk1.7.0_09 /usr/lib/jvm/jdk1.7.0_09

Now we need to set up a symbolic link so that we can run Java from everywhere:

 sudo ln -fs /usr/lib/jvm/jdk1.7.0_09/bin/java /usr/bin/java

Now check that Java is all installed correctly by checking the version using:

java -version

Which in this case should give:

java version “1.7.0_09″
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) Client VM (build 23.5-b02, mixed mode)

Now you can set up your JAVA_HOME variable at a system level so other applications can use Java by editing “/etc/environment”:

sudo nano /etc/environment

Now add the following line to point to your newly installed Java:


Now if you open up a new session (not your currect session) and type “echo $JAVA_HOME” you should see the path “/usr/lib/jvm/jdk1.7.0_09″ which means the variable has been set correctly.