Previously I have looked at Flask (Python) and Django (Python) web servers running on the Raspberry Pi. Today I am going to look at Apache Tomcat, a web server which is more geared towards running Java based applications.
I’m currently looking at Java and so will be using the JDK on my Raspberry Pi. For this install I am using a Raspberry Pi 3 and Raspbian Stretch.
Install Java Development Kit (JDK)
- sudo apt-get update
- sudo apt-get install default-jdk
- java -version
- sudo nano /etc/environment
Install Apache Tomcat
- sudo apt-get install tomcat8
- Open a web browser and navigate to the your Raspberry Pis IP address with :8080 on the end, if you need to find the ip address open terminal and type ifconfig. The :8080 is to tell the browser to connect to the port 8080
Installing a webapp (Jenkins in this example)
Java webapps come in .war format. For this example I’m using Jenkins (https://jenkins.io/download/).
- Download the .war file from https://jenkins.io/download/
- Copy the file from the download location to /var/lib/tomcat8/webapps e.g. sudo cp /home/pi/Downloads/jenkins.war /var/lib/tomcat8/webapps/
- Open a browser to the Raspberry Pi IP address, port 8080 (:8080), /jenkins/
- Jenkins requires a key (the initial page says where the secrets file is) and then it is ready to configure