Note
The Oracle Java Runtime Environment (SRE) has been removed from the official software repositories of Ubuntu and only provides a binary (.bin) version. You can get the JRE from the Java SE Downloads.
-
Download the appropriate version of the JRE, such as jre-6u31-linux-i586.bin, for your system and unpack it directly under /opt/java/<32 or 64>.
-
Make the file executable:
sudo chmod 755 /opt/java/32/jre-6u31-linux-i586.bin
-
Go to the new folder:
cd /opt/java
-
Execute the file:
sudo ./jre-6u31-linux-i586.bin
-
Accept the license terms to continue installing the JRE.
-
Tell the system that there’s a new Java version available:
sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/32/jre1.6.0_31/bin/java" 1
Note
If updating from a previous version that was removed manually, execute the above command twice, because you’ll get an error message the first time.
-
Set the new JRE as the default:
sudo update-alternatives --set java /opt/java/32/jre1.6.0_31/bin/java
-
Make sure your system is now using the correct JRE:
$ sudo java -version java version "1.6.0_31" Java(TM) SE Runtime Environment (build 1.6.0_31-b04) Java HotSpot(TM) 64-Bit Server VM (build 20.1-b04, mixed mode)