How To Install JasperReports on Ubuntu 22.04 LTS
In this tutorial, we will show you how to install JasperReports on Ubuntu 22.04 LTS. For those of you who didn’t know, JasperReports library is an open-source reporting engine that is entirely written in Java. Developers can use JasperReports as a stand-alone reporting and analytics library server. It is entirely written in Java and it is able to use data coming from any kind of data source and produce pixel-perfect documents that can be viewed, printed, or exported in a variety of document formats including HTML, PDF, Excel, OpenOffice, and Word.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the JasperReports on Ubuntu 22.04 (Jammy Jellyfish). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
Prerequisites
- A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install JasperReports on Ubuntu 22.04 LTS Jammy Jellyfish
Step 1. First, make sure that all your system packages are up-to-date by running the following apt
commands in the terminal.
sudo apt update sudo apt upgrade sudo apt install wget apt-transport-https gnupg2 software-properties-common
Step 2. Installing Java OpenJDK.
JasperReports is based on Java, so you will need to install the Java JDK on your server. Let’s run the command below to install default JDK version 11:
sudo apt install default-jdk
Verify the Java version using the following command:
java --version
For additional resources on installing and managing Java OpenJDK, read the post below:
Step 3. Installing MariaDB Database.
By default, the MariaDB is available on Ubuntu 22.04 base repository. Now run the following command below to install the latest version of MariaDB to your Ubuntu system:
sudo apt install mariadb-server mariadb-client
After successfully installing, enable MariaDB (to start automatically upon system boot), start, and verify the status using the commands below:
sudo systemctl enable mariadb sudo systemctl start mariadb sudo systemctl status mariadb
Confirm the installation and check the installed build version of MariaDB:
mariadb --version
For additional resources on installing MariaDB, read the post below:
Secure MariaDB installation.
By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation
script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:
mysql_secure_installation
Configure it like this:
- Set root password? [Y/n] y - Remove anonymous users? [Y/n] y - Disallow root login remotely? [Y/n] y - Remove test database and access to it? [Y/n] y - Reload privilege tables now? [Y/n] y
Once the MariaDB is installed, log into the MariaDB with the following command:
mysql
Once you are logged in, create a user and set a password with the following command:
MariaDB [(none)]> grant all on *.* to master@localhost identified by 'your-strong-password'; MariaDB [(none)]> flush privileges; MariaDB [(none)]> exit;
Step 4. Installing Apache Tomcat Server.
First, create a user and group accounts to use with Tomcat:
groupadd tomcat useradd -s /bin/bash -g tomcat -d /opt/tomcat tomcat
Next, we create a Tomcat account home directory, then download and extract Tomcat content into the directory:
mkdir /opt/tomcat wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.83/bin/apache-tomcat-8.5.83.tar.gz sudo tar -xzvf apache-tomcat-8.5.83.tar.gz -C /opt/tomcat --strip-components=1
Now set proper permission and ownership to the Tomcat directory:
sudo chown -R tomcat: /opt/tomcat sudo sh -c 'chmod +x /opt/tomcat/bin/*.sh'
Then, create a systemd
service file for Tomcat using the following command below:
sudo nano /etc/systemd/system/tomcat.service
Add the following file:
[Unit] Description=Tomcat webs servlet container After=network.target [Service] Type=forking User=tomcat Group=tomcat RestartSec=10 Restart=always Environment="JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64" Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom" Environment="CATALINA_BASE=/opt/tomcat" Environment="CATALINA_HOME=/opt/tomcat" Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid" Environment="CATALINA_OPTS=-Xms1024M -Xmx2048M -server -XX:+UseParallelGC" ExecStart=/opt/tomcat/bin/startup.sh ExecStop=/opt/tomcat/bin/shutdown.sh [Install] WantedBy=multi-user.target
Save and close the file, then reload the systemd
daemon to apply the changes:
sudo systemctl daemon-reload sudo systemctl start tomcat
Step 5. Installing JasperReports on Ubuntu 22.04.
Now we switch the user to Tomcat and download the JasperReports file with the following command below:
sudo su - tomcat wget https://sourceforge.net/projects/jasperserver/files/JasperServer/JasperReports%20Server%20Community%20edition%208.0.0/TIB_js-jrs-cp_8.0.0_bin.zip
Next, unzip the downloaded file:
unzip TIB_js-jrs-cp_8.0.0_bin.zip
Then, copy the MySQL property file with the following command:
cp jasperreports-server-cp-8.0.0-bin/buildomatic/sample_conf/mysql_master.properties jasperreports-server-cp-8.0.0-bin/buildomatic/default_master.properties
Now run the commands below to open the newly created file:
nano jasperreports-server-cp-8.0.0-bin/buildomatic/default_master.properties
Add database configuration details as shown below:
# if linux package managed tomcat instance, set two properties below CATALINA_HOME = /opt/tomcat CATALINA_BASE = /opt/tomcat #database type dbType=mysql #database location and connection settings dbHost=localhost dbUsername=jasperadmin dbPassword=strong-your-password
Save and close the file then install the JasperReports with the following command:
cd jasperreports-server-cp-8.0.0-bin/buildomatic/ ./js-install-ce.sh
Once the installation is complete, you will get the following output:
install-normal-ce: [echo] Installation successfully completed! BUILD SUCCESSFUL Total time: 2 minute 16 seconds Checking Ant return code: OK
Finally, now restart the Tomcat service to apply the changes:
sudo systemctl restart tomcat
Step 6. Configure Firewall.
Now we set up an Uncomplicated Firewall (UFW) with Apache to allow public access on default web ports for HTTP and HTTPS:
sudo ufw allow OpenSSH sudo ufw allow 8080/tcp sudo ufw enable
Step 7. Accessing JasperReports Web Interface.
Once successfully installed, open your web browser and access the JasperReports installation wizard using the URL http://your-IP-address:8080/jasperserver/
. You will be redirected to the following page:
Congratulations! You have successfully installed JasperReports. Thanks for using this tutorial for installing JasperReports on Ubuntu 22.04 LTS Jammy Jellyfish system. For additional help or useful information, we recommend you check the official JasperReports website.