Java is one of the most popular programming languages, and if you’re running a Linux installation, you’ll probably need the Jave Runtime Environment (JRE) for the Standard Edition (SE). If you have a browser like Firefox running, you’ll need to configure it to use the JRE plugin afterwards as well. In this article, I show you how to obtain the latest version of JRE, install it, and configure it for use with a browser like Firefox.
Installing the Latest Version of the Java Runtime Environment
While the regular package managers of Linux distros like CentOS/RHEL and Ubuntu can install the JRE, it’s best to obtain the latest RPMs directly from the Oracle website. To do this, visit this webpage and click on the “JRE Download” button as shown in the screenshot here:
This will take you to a page with all the RPMs and executable files for the various operating systems. To download anything, you first need to accept the License agreement. If you’re using Linux, you also have to obtain the correct RPM for your particular architecture. To find out if you’re running a 32 or a 64 bit installation, type the following command:
If it returns something like “x86_64”, it means your architecture is 64 bit. A value of “i386” or something else means you have a 32-bit architecture. Get the appropriate RPM from the list as shown below:
Copy the download link and use it with wget to place the file on your Linux server like this:
wget [download link]
Once the package is on your system, use your package command to install the rpm. If you’re using CentOS/RHEL, use the following command:
yum localinstall [package name]
Unfortunately if you’re using a distro like Ubuntu or Debian, it’s best to straight up compile it from source, or use the (possibly outdated) JRE packages using your package manager like “apt-get”. If you want to compile from source using the “tar.gz” files listed in the screenshot above, this article should get your started. And if you want to install from source safely so that you can always uninstall afterwards, consider using the “checkinstall” utility.
Once the JRE is installed on your system, you can get its version by typing:
And this will print out the version information as shown here:
Installing the JRE Plugin for Browsers
Installing the JRE on your system doesn’t mean that browsers like Firefox will be able to automatically pick it up. That’s because they don’t know where it is, and the exact location of the plugin depends from system to system. So first, let’s find out two things:
- The location of the Java installation and the plugin file;
- The location of your JRE plugin.
We will then create a symbolic link from (2) to (1).
Getting the Mozilla Plugin Locations:
The following command will give you the location of the mozilla installation:
Each of these two folders will have a directory called “plugins”. So we need to place the plugin files in the following two locations:
Getting the JRE Plugin Location:
Type the following into your Linux terminal:
readlink -f $(which java)
This will give you the location of the “java” command like this:
The output is:
This means that my Java installation directory is:
Now, depending on your architecture, the location of the plugin file is:
[Java installation directory]/lib/i386/libnpjp2.so (for 32-bit architecture)
[Java installation directory]/lib/amd64/libnpjp2.so (for 64-bit architecture)
Creating a Symbolic Link from the Plugin File to the Browser Plugin Directories:
Finally, putting these two together, we create a link from the plugin file, to the two plugin directories. First, navigate to each plugin directory. For example:
And type the following into the command line:
ls -s /usr/java/jre1.8.0_144/lib/amd64/libnpjp2.so .
Replace the plugin file above with whatever path you obtained in the previous step. This will create a symbolic link as shown here:
Now repeat the process for the other mozilla plugin directory and you’re all done! You have successfully installed the JRE package for Linux and also placed the plugin file in the mozilla folder! Note that if you’re using a different browser, you’ll need to find out where it’s storing its plugins and change the steps accordingly.