How to build the Apache Tomcat Native Library?

2 weeks ago 22
ARTICLE AD BOX

Ref doc:

https://tomcat.apache.org/native-1.3-doc/index.html

install dev tools

sudo apt install build-essential libapr1-dev libssl-dev -y

Prepare work dir under your Downloads directory

mkdir -p ~/Downloads/wk-000

Download Tomcat 9

cd ~/Downloads/wk-000 wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.113/bin/apache-tomcat-9.0.113.tar.gz

Unzip Tomcat 9

tar -zxvf apache-tomcat-9.0.113.tar.gz

Unzip Tomcat Native Source

You don't need to download the Tomcat native source code separately; it's already included in the Tomcat bin directory.

cd ~/Downloads/wk-000/apache-tomcat-9.0.113/bin tar -zxvf tomcat-native.tar.gz

Run Command configure

note: change /home/demo to your user directory path.

cd ~/Downloads/wk-000/apache-tomcat-9.0.113/bin/tomcat-native-1.3.1-src/native ./configure --with-apr=/usr/bin/apr-1-config \ --with-java-home=$JAVA_HOME \ --with-ssl=/usr \ --prefix=/home/demo/Downloads/wk-000/apache-tomcat-9.0.113

Run Command make and install

make make install

If everything ok , you will see the message:

Libraries have been installed in: /home/demo/Downloads/wk-000/apache-tomcat-9.0.113/lib

Add setenv.sh

nano ~/Downloads/wk-000/apache-tomcat-9.0.113/bin/setenv.sh

Add two lines

CATALINA_OPTS="$CATALINA_OPTS -Djava.library.path=$CATALINA_HOME/lib" export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CATALINA_HOME/lib

make setenv.sh as executeable

chmod +x ~/Downloads/wk-000/apache-tomcat-9.0.113/bin/setenv.sh

Start tomcat

cd ~/Downloads/wk-000/apache-tomcat-9.0.113/bin ./startup.sh

Verify

Run Command 1: (under ~/Downloads/wk-000/apache-tomcat-9.0.113/bin )

grep -E "Native|APR" ../logs/catalina.out

If suceess, you will see:

20-Jan-2026 14:10:02.625 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded Apache Tomcat Native library [1.3.1] using APR version [1.7.2].

Run Command 2: (under ~/Downloads/wk-000/apache-tomcat-9.0.113/bin )

grep "OpenSSL" ../logs/catalina.out

If suceess, you will see:

20-Jan-2026 14:10:02.626 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true] 20-Jan-2026 14:10:02.629 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 3.0.13 30 Jan 2024]

Clean tomcat-native directory

rm -rf ~/Downloads/wk-000/apache-tomcat-9.0.113/bin/tomcat-native-1.3.1-src

The test and verification have now been successful. You can move the apache-tomcat-9.0.113 directory to another directory.

Read Entire Article