Installing the Tomcat APR native library allows us to work smoothly with both: the JSSE and the OpenSSL implementation. Installing it offers the Tomcat the ability to use the Apache Portable Runtime (APR) which provides superior scalability, performance, and better integration with native server technologies (like Apache http Server, etc).
It will be nice if you could have some time to dig deeper by accessing the detailed information at the official documentation here or here. Also, since the APR-based native library is linked to Apache Tomcat, it seems necessary that you have already installed it on your system. See my post here on how you can do that. This is because the compressed .tar file is shipped together with the Tomcat distribution.
The process is pretty straightforward and consists of running just the 3 “standard” commands: configure, make and make install. We will se them later in the 3 steps following.
If you have already installed Tomcat, you are probably familiar with the Tomcat folder structure. So, you can find the compressed .tar file inside the Tomcat /bin subfolder. The file is named “tomcat-native.tar.qz” and it contains the source code for creating/installing the Apache Portable Runtime (APR) based Native library for Tomcat. So, when you unzip this file, a new (sub) folder is created (inside the /bin folder) with the name: “/tomcat-native-1.2.35-src“.
You can see below the contents of the “/tomcat-native-1.2.35-src” (sub)folder, as well as the /native (sub) folder marked:
The native (sub)folder is there where you can find the .configure script.
Step 1 – Run the .configure script
You can run the ./configure script from within the /native (sub)folder:
If you get an error like “error:APR could not be located….” as you can see below, then you have to install the APR before proceeding further
👉 See how to install it, at my related post here.
After you have installed the APR libraries you can re-run the ./configure script as before. This time the APR seems it is already installed. However, this time we have to provide our Java Home location.
If you don’t know exactly, which Java version is installed or is running in your system, and also you want to find out where the JDK corresponding to the java’s running version, is, you can use a number of Linux commands. Below you can see some of them.
The last one perhaps is the “winner“.
➜ readlink -f $(which java)
So, for the default running version of Java (which is java version “1.8.0_251”), the jdk is located at:/opt/jdk/jdk1.8.0_251/bin/java.
Next, we re-run the ./configure script, however this time we will run it, by providing the “–with-java-home=/opt/jdk/jdk1.8.0_251” parameter.
➜ ./configure --with-java-home=/opt/jdk/jdk1.8.0_251
As you can see above, this time we didn’t get any errors. The final line of the output states: “config.status: executing default commands”. Such a message usually indicates that we can proceed to build our package.
Step 2 – Build the package (the library)
Use the standard GNU make command:
👉 You can see the whole output of the make command at the gist here.
After running the make command, ensure that you didn’t get any errors, like here. After that, you can proceed to the final step of the installation of our package.
Step 3 – Install the package (the library)
In this final step, we simply use the make install command, which installs the binaries (the libraries) built into their final locations.
➜ sudo make install
This time you can see the output below:
The importance of the above output is to know where the Tomcat APR native libraries have been installed. As you can see, they have been installed into the “/usr/local/apr/lib” folder.
Enjoy, and thank you for reading!