Java | Install Oracle Java JRE on Ubuntu

Java | Install Oracle Java JRE on Ubuntu

Recently Ubuntu has stopped automagically install Oracle Java for you when the OS is installed. This is because in August 2011, Oracle removed the license that allowed Linux distributions to package Java for use in its repositories. Therefore, there are two options for users of Linux to install a Java JRE. The first option is to install OpenJDK through the package manager, which is a open-source implementation of the Java Platform. If you really need Oracle Java though to run a certain Java program, then the second option is to install the Oracle Java JRE manually. I will be going through the manual steps of downloading and installing Oracle Java in Ubuntu.

The first step is to download a tar of the Oracle Java JRE. You can download this from the Java Downloads for Linux page on the Oracle Java site. For Ubuntu, you should download the one that is titled “Linux”, you do not want the “Linux RPM” one. If you have a 64bit OS, then you can download the “Linux x64” version. Once you have downloaded the tar file, open a terminal window and change into the directory where you saved the file.

Make a directory where you want to put the Java binaries in, I am going to put mine in /opt/java, but you can put them anywhere you want.

Extract the contents of the tar file.

The Oracle Java JRE binaries are now installed. All you need to do now is define the $JAVA_HOME variable which is the JRE folder path location (you will have to change it according to your version) and add onto the $PATH variable the location of the JRE bin folder. Execute the following commands to create/update those variables.

When you restart your terminal, it will read the .profile file and update those environment variables.  Note that if it does not work then you might be using a shell other than bash or there is already start up scripts in your home directory such as a .bashrc file.

To check if everything is setup correctly, check your Java version and if you get the following output you should be all set! Note that depending on which version of Java you install, your output might look a little different than mine.

Also, note that if you have a jnlp file and you want to run Java Web Start from the terminal, use the javaws program.

Finally, if you want to update to a new Oracle Java JRE version, just follow the same procedure and update the $JAVA_HOME and $PATH variables according to which java version you updated to.

Comments are closed.