- by Martin Kaba
- on Wed Feb 1, 2012
Ubuntu 9.10 was the last version to have Java Runtime Environment in its repositories. Since then all other versions come with the community-built OpenJDK that has little or nothing to envy the previous, Oracle’s JRE.
If you installed a recent version of Ubuntu from scratch you certainly don’t have Java Runtime Environment running in the background. Maybe you don’t really need it at all. As usual, there’s yet another security hole to patch. If you desperately need it then this is how you can quickly install it on Ubuntu 12.04, 12.10, 13.04 – via the PPA.
Use this custom PPA from webupd8team/java with all the risk involved. The PPA provides the full Oracle JDK7 package, that is including Java JDK, JRE and the Java browser plugin for Firefox
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
Check the java version with:
That’s it. Now in the Firefox Location bar, type about:config and press Enter. You’ll see Java(TM) Plug-in 1.7.x_xx. Go to the official java test page for further confirmation of the correct installation of JRE on your browser.
To automatically set the environment variables install the following package:
sudo apt-get install oracle-java7-set-default
The second method is a little longer, less risky than the first, but the outcome is practically the same.
First download Sun JDK 7 to your download folder and extract manually or with
tar -xvf jdk-7uXX-linux-x64.tar.gz
Move the extracted folder to /usr/lib/jvm/ with
sudo mv jdk1.7.x_xx /usr/lib/jvm/
Now install and set the environment variables
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.x_xx/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.x_xx/bin/java 1
sudo update-alternatives --config javac
sudo update-alternatives --config java
You’re done. Test with the above mentioned methods.
To uninstall Oracle’s JRE and roll-back to OpenJDK, use the command-line again:
sudo apt-get remove oracle-java7-installer