AWS, Cloud Computing

3 Mins Read

Deploying Java Web Application on Amazon EC2 server using a WAR File

Voiced by Amazon Polly


Amazon Elastic Compute Cloud (EC2) provides scalable compute capacity in the cloud, allowing developers to run virtual servers known as instances. In this blog post, we will explore deploying a Java web application on an Amazon EC2 server using a Web Application Archive (WAR) file. This step-by-step guide will cover the prerequisites, the benefits of using Amazon EC2, and the necessary steps to set up your Java application.


Amazon EC2 is a key service in Amazon Web Services (AWS), empowering businesses and developers to deploy applications quickly and scale resources based on demand. Deploying a Java web application on Amazon EC2 offers flexibility, reliability, and cost-effectiveness.

A WAR file simplifies the deployment process, encapsulating the entire application into a single archive.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started


Before diving into the deployment process, ensure you have the following in place:

AWS Account: Open the AWS Management Console by creating an AWS account.

Amazon EC2 Instance: Set up an Amazon EC2 instance with the necessary security groups allowing inbound traffic on required ports (e.g., port 8080 for Tomcat).

Java Development Kit (JDK): Install JDK on your Amazon EC2 instance to run Java applications.

Step-by-step guide

Step 1: Connect to Your Amazon EC2 Instance

Use SSH to establish a connection to your Amazon EC2 instance:


Step 2: Installing the Default JRE/JDK

Update the package list and install Java:

Verify the Java installation:

Step 3: Create a Tomcat user

Create a new tomcat group

Now create a new tomcat user that is member of tomcat group

Step 4: Now install tomcat9

Go to this folder

Now install the tomcat to this folder

Step 5: Update the permissions

Assign ownership of the full installation directory to the Tomcat group:sudo chgrp -R tomcat /opt/tomcat

Need to know where JAVA is installed

Now copy this Java path and store it somewhere

Go to this file and update the content

Next, reload the system daemon

Start the Tomcat service

Check that it started without errors

Deploy Your Java Application

  1. Manual Deployment

Your WAR file should be uploaded to the Tomcat webapps directory:

2. Automatic Deployment

Edit the server.xml file:

Add the following lines inside the <Host> element:

Replace your-application-name with the desired context path for your application.

Access Your Java Application

Go to your Amazon EC2 instance’s public IP address:


Deploying a Java web application on an Amazon EC2 server is a straightforward process that offers scalability, cost-effectiveness, and ease of management. Amazon EC2’s flexibility and variety of instance types make it ideal for hosting a wide range of applications. Following the steps outlined in this guide, you can quickly set up your Java application on an Amazon EC2 instance and leverage the benefits of cloud computing.

Drop a query if you have any questions regarding Amazon EC2 and we will get back to you quickly.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training PartnerAWS Migration PartnerAWS Data and Analytics PartnerAWS DevOps Competency PartnerAmazon QuickSight Service Delivery PartnerAmazon EKS Service Delivery PartnerAWS Microsoft Workload PartnersAmazon EC2 Service Delivery Partner, and many more.

To get started, go through our Consultancy page and Managed Services PackageCloudThat’s offerings.


1. Can I deploy multiple Java web applications on the same Amazon EC2 instance using Tomcat?

ANS: – Yes, Tomcat supports deploying multiple applications on the same instance. You can configure multiple contexts within the server.xml file to achieve this.

2. What security considerations should I keep in mind when deploying on Amazon EC2?

ANS: – Ensure that your security groups only allow necessary inbound traffic, and regularly update and patch your instance to address any security vulnerabilities.

3. How can I scale my Java application on Amazon EC2 to handle increased traffic?

ANS: – You can use Elastic Load Balancing (ELB) to distribute incoming traffic across multiple Amazon EC2 instances, ensuring high availability and scalability.

WRITTEN BY Rohit Kumar

Rohit Kumar works as a Research Associate (Infra, Migration, and Security Team) at CloudThat. He is focused on gaining knowledge of the Cloud environment. He has a keen interest in learning and researching emerging technologies.



    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!