Welcome back, Reader.  This article explains how to Build and Run Java Web Application into Tomcat Runtime environment.

Infrastructure Setup

1. Create two EC2 instances on AWS cloud to Build the source and then Run the application.

1. JDK 1.8 or above must be installed and configured to Build and Deploy Java applications. Hence, Run below commands to setup JDK [Java Development Kit] on both Build and Deploy servers.

Download JDK Binary

  1. cd /opt
  2. wget https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_linux-x64_bin.tar.gz
  3. tar -zxvf openjdk-11+28_linux-x64_bin.tar.gz

Define PATH variable in /etc/profile as below

  1. export JAVA_HOME=/opt/jdk-11
  2. export PATH=$PATH:/opt/jdk-11/bin

Verify JAVA version

  1. java –version

2. Download and Install Apache Maven on Build Server

Download Maven Binary

  1. cd /opt
  2. wget https://dlcdn.apache.org/maven/maven-3/3.8.6/binaries/apache-maven-3.8.6-bin.zip
  3. unzip apache-maven-3.8.6-bin.zip

Define PATH variable in /etc/profile as below

  1. export M2_HOME=/opt/apache-maven-3.8.6
  2. export PATH=$PATH:/opt/apache-maven-3.8.6/bin

Verify JAVA version

  1. mvn –version

3. Download and Install Apache Tomcat on App server

Download Tomcat Binary

  1. cd /opt
  2. wget https://dlcdn.apache.org/tomcat/tomcat-8/v8.5.83/bin/apache-tomcat-8.5.83.zip
  3. unzip apache-tomcat-8.5.83.zip
  4. cd /opt/apache-tomcat-8.5.83/bin/
  5. chmod +x ./*


  1. Login to Build Server and clone the Bitbucket source code repository
    1. cd /opt
    2. git clone https://dptrealtime@bitbucket.org/dptrealtime/java-login-app.git
  2. Build the Java Source
    1. cd /opt/java-login-app
    2. mvn package
  3. Verify that artifacts .war are created in ‘target’ folder
    1. ls -l target


  1. During the Build step artifacts were created in Build Server target directory. Need to copy the Maven Artifact .war to Tomcat  webapps directory
  2. Login to Build server copy the .war to app server [Example command as below]
    1. scp dptweb-1.0.war ec2-user@
  3. Start Tomcat Services
    1. /opt/apache-tomcat-8.5.83/bin
    2.  ./catalina.sh start
  4. Verify that port 8080 is in LISTEN state
    1. netstat -tupln | grep -i 8080


Browse the application from internet browser by sending the http request to Port 8080 as below. Here “dptweb-1.0” is the application name deployed into Tomcat webapps.

If the Server IP is already configured as A record in the DNS then, You should be now able to access the web application using the domain like below.


Goal of this article to understand the simple Java Web application Build and Deployment process to Run the application in Tomcat runtime environment.  Hope this article helps!

© Edwiki Trainings – Click HERE If you are interested to learn more on Cloud & DevOps stack.

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like