An ad-free and cookie-free website.
Apache Solr version 6, (we will install version 7 in the next tutorial) the latest version as of this writing, requires the Java Runtime Environment 1.8 (JRE) or greater.
Videos can also be accessed from our Apache Solr Search Playlist on YouTube (opens in a new browser window).
How to Install Java JRE for an Apache Solr Installation (13:15)
The full blown Java Development Kit (JDK) at the time of this writing is Version 8. So you are aware and to avoid confusion, the official version number is 1.8, and people often refer to version 8 as the same thing.
The full Java Development Kit (JDK) includes the required Java Runtime Environment for Apache Solr. So if you install the JDK this satisfies the requirements. However, the JDK is more suited for those who want to compile their own Java programs. Also, some software requires the whole JDK, but Apache Solr does not. So you should decide whether it fits your needs to install the full JDK. Here we will focus on the JRE.
The Java Runtime Environment (JRE) on the other hand is the software required to run Java programs, in this case Apache Solr. If you would like a smaller footprint on the server then install only the JRE.
If you are unsure as to whether you have Java installed on your system
you can run
As you can see, I have version 1.8, or 8, after completing the steps in this tutorial for my Debian 8 Jessie operating system.
Assuming you only want to install the JRE, the next consideration
depends on which version of Debian you have. On Debian 8 Jessie the
default JRE downloaded using the default package manager using
apt-get install will download the JRE
version 1.7 which is not suitable for Apache Solr 6 (and 7). On Debian 9
Stretch the default JRE is 1.8, so that is easy.
To see this on Debian 8 Jessie, first off start with a
sudo apt-get update to update the
cache of all stable packages to your local system. As of the time of
this writing there are about 54,000 packages.
Next, to see which JRE programs are available use
apt-cache -n search jre. This will
scan the 54,000 packages and where it finds
jre in the name field only, specified
-n option, it will print a
The packages we are interested in discussing are
default-jre-headless. Also, later we
will cover the JRE version 8 which is similar to these two files
Now to learn more about any of these packages you can use the
apt-cache showpkg command. So let's
review the first few lines and last lines of the
default-jre output using that command.
The output is about 170 lines long.
Reviewing the output, we can see that the version is 1.7-52, and as mentioned for Apache Solr 6 (and 7), we need the JRE version 1.8 or greater, so on Debian 8 Jessie we will need to install a different version, which I will explain shortly.
On Debian 9 Stretch, if you do an
apt-cache showpkg default-jre as of
the date of this document, the version number is 1.8-58, so this
package will be suitable for a Solr 6 (and 7) installation. It can be
sudo apt-get update
sudo apt-get install default-jre if
you are using a GUI, or
sudo apt-get install default-jre-headless
if you are using a headless server (see Consideration 3).
The next thing to consider is your environment. Are you installing the Java JRE on a machine with a GUI (graphical user interface) or on a command line only server? On the latter, you will be able to save space by installing only the components you need.
For a GUI environment, you will need the full version of the
default-jre. So again, as mentioned
earlier, if you are on Debian 9, and you want the GUI version, then
install with the command
sudo apt-get install default-jre.
If you intend to run Apache Solr on a server using the command line,
sufficient. This will allow you to save space by installing only the
portion of the JRE needed to run on a headless server.
apt-cache showpkg from
above, here is a subset of the output.
So again, on my Debian 8 Jessie server, the default using the headless package will be 1.7, so we will need another way to get 1.8 which is the next topic.
On Debian 9 Stretch, the
default-jre-headless package will
install version 1.8 by default, adequate for Solr 6 (and 7).
Now since the
default-jre-headless for Debian 8
Jessie automatically download version 1.7, we need to get version 1.8
from Jessie backports.
Debian provides information about backports at https://backports.debian.org/Instructions/ including caveats and download instructions. In summary, backports are not as fully tested by Debian and may come with incompatibilities with the stable release, so Debian provides all of the appropriate warnings.
There are two steps to download from Jessie backports.
We need to point the Debian Advanced Package Tool to this new jessie-backports repository, which is not standard in a default Debian installation.
There are two ways to do this. First, we can add a line to the file
/etc/apt/sources.list. Second, we can
add a new file to the directory
/etc/apt/sources.list.d/. Both will
point the Debian Advanced Package Tool to where to find packages,
meaning the commands
apt-cache both look here for
the URL of where to find packages.
Using the first method, with your preferred text editor, add the
following line to
/etc/apt/sources.list using superuser
privileges. For example,
sudo vim /etc/apt/sources.list.
Save and close the file. Now when you perform an
apt-get update it will access both
the stable and backports repositories.
Next, we will install the JRE 1.8 from this newly connected
jessie-backports repository. Recall that the
install version 1.7, so in order to install version 1.8, we need to
instruct Debian to go to the backports and search for a different file
name. The first file is
openjdk-8-jre for the full GUI version
and for the command line version use
openjdk-8-jre-headless. As always
start with an update.
Since we added another repository with the backports, the update is
required to pull the list of files in the backports for Jessie. Once
that is complete, we will do a
sudo apt-get install with the
-t option to tell Debian to get the
target release, or the one specified, instead of the default. Next, we
point to the
install two files,
The point of the last part
ca-certificates-java has to do with
verifying the download with a certificate authority. We are instructing
Debian to also download the version of
ca-certificates-java from the
backports, which is recommended.
In my case, as I have not installed
ca-certificates-java before there are
two versions available. First, the older version
20140324 which would be downloaded from the Jessie
stable repository and another version
20161107~bpo8+1 which is downloaded from the
backports. Information on these packages can be found on the Debian
Package Manager documentation located at
To verify that everything worked as planned, check the version number of the JRE after the installation using backports for Debian 8 Jessie.
Again, this would be much easier using the latest version of Debian 9 Stretch, but using the backports gives you an alternative is you are using Debian 8 Jessie, like I am here.
The fifth consideration, and an alternative to using the Debian package manager, is to download files straight from Oracle at http://www.oracle.com/technetwork/java/javase/downloads/index.html.
Read appropriate documentation on the Oracle website for installation instructions, as it is beyond our scope here.
Now you should have version 1.8 of the JRE installed on your system, whether that be on Debian 8 Jessie or Debian 9 Stretch. You are ready for the installation of Apache Solr 6 (and 7).
Certain aspects of Apache Solr are tricky so if you need help with this please feel free to reach out on social media, including at our FactorPad YouTube Channel.
Q: Will this work with Ubuntu?
A: You will have to check yourself, but because Ubuntu is an offshoot of Debian and uses the Advanced Packaging Tool much of the functions described here will likely work with Ubuntu as well.
Our YouTube Channel offers a lot of free learning resources. Connect and see what else is available.
A newly-updated free resource. Connect and refer a friend today.