Home  >  Blog  >   AWS  > 

How to deploy a Java enterprise application to AWS cloud

Rating: 4
  1. Share:
AWS Articles

As we all know, Amazon Web Services (AWS) is a very popular name and a wonderful platform for Java application development to run Java workloads which offer for deploying and managing both off the shelf as well as custom applications. The new customers are unclear as to which method will allow them to quickly get their application running up when planning to deploy a java web application to AWS for the first time. AWS is an evolving and comprehensive cloud computing platform provided by Amazon for a mix of infrastructure as a service (IaaS), platform as a service (PaaS), and packaged software as a service (SaaS).

Amazon.com launched AWS in 2006 from its internal infrastructure to handle all online retail operations. It was one of the first companies to introduce pay as you go cloud computing model that scales to provide users with storage as needed. AWS offers services from dozens of data centers spread across availability zones in regions across the world.

An availability zone is a location that typically contains multiple physical data centers, whereas a region is a collection of AZs in geographic proximity connected by low-latency network links. Virtual machines are spun up by AWS customers to replicate data in different AZs to achieve a highly reliable infrastructure that is resistant to failures of individual servers or an entire data center. In this article, we will provide you with a quick overview so that you get an idea about deploying your Java enterprise application on the AWS cloud.

Steps to deploy Java Enterprise Application in AWS Cloud

Step 1: Signup a Permanent Account

In order to begin, you are required to sign up for an AWS account which can be done via aws.amazon.com. Click on the button like "Create an AWS account" or "Sign in to the Console" which will take you to the account creation or sign in the screen that looks like depicted below.

Amazon AWS cloud

If you are a regular customer who does shopping from Amazon, then you don't need to sign up again; you can continue with AWS from the same shopping account. But, if you are creating a brand new account then you definitely have to fill out some account information as given below.

[Related Article: Brief Introduction To Amazon Web Services (AWS)]

Amazons AWS cloud

After filling out all of your personal and business information you also need to give payment information. Amazon does not charge a single penny for the first 12 months for using AWS. All of the payment procedure begins once the free trial months get completed. The payment information contains to enter your credit or debit card data and after entering it, you will have to verify your identity by receiving a call or typing a PIN on the assigned phone number/email.

Related Blog: [Best Java EE Frameworks]

Amazon AWS CloudAmazons AWS cloud

After everything is filled up, you need to select the support plan that gives you an opportunity to have access to set everything up. Unless you are a large corporation you don't need to choose anything other than their basic support plan which is totally free and gives you access to their online documentation.

Amazons AWS cloud

And there you go! After successfully creating the account, you can log in to the console and type your account information that you created previously to log in to your AWS dashboard. Then comes the next step to create a Tomcat server using Amazon Web Services called Elastic Beanstalk product for Java development services.

 MindMajix YouTube Channel

Step 2: Create a Tomcat Server with the help of Elastic Beanstalk

Next, we are going to create a virtual server in the cloud for an instance that will be running a Tomcat server which is known as a t2.micro instance, its part of Amazon's free tier offering. To create this server, you need to login to your AWS dashboard and navigate to Elastic Beanstalk by clicking on the services option.Amazons AWS Cloud After clicking, you are going to Get Started by entering a few simple details to get your environment up and running. 

  • Mention the name of your application or product you are building.
  • Choose a platform - Tomcat platform for launching Java web app.
  • Lastly, you can select to launch a simple application or WAR file.

Once you hit the 'Create Application' button, AWS will proceed to create your environment for you.

Amazons AWS cloud

This usually takes about a few minutes and then presents with a familiar screen.Amazons AWS cloud
Before working in Elastic Beanstalk, you need to take care of a few points.

  • Your existing instance region which you select. If you change regions, you will not find the elastic beanstalk instance that you just created. 
  • Your application's tab if you have plenty of applications in the same region to switch between them via this tab.
  • Your application's URL to see your app in all its glory.
  • Your application's version to specify unique version numbers for each build.
Checkout AWS Tutorials

After your app is launched, take a note of your screen to go ahead and click on your app's URL to see in action.Amazons AWS cloud
We also need to launch our own code onto this Linux server with Tomcat installed on it. To create your new Java development company cloud environment, you need to look at some other important configurations.

Change your t2.micro instance by clicking on the 'Instance type' label.Amazons AWS cloud
Once the environment is accustomed to seeing, you will see its updates on the screen.

All of that INFO status will be changed to OK health status once your new t2.micro instance is ready to go.

want to take your cloud knowledge next level click here to learn What is Cloud Computing

Step 3: Prep your Code for Deployment

You got a running instance in elastic beanstalk but it does not contain your application's code yet. To insert your code you have two options to unfold:

  • Created an application using SpringBoot
  • Does not create an application using SpringBoot

If you have created your application code using SpringBoot then you can skip this step. But for those, you haven't, here's all that you can do. Firstly, you have to create a deployable WAR file from your project by invoking a Maven install on your code-base. Just be sure to get your maven pom.xml as a WAR and not JAR. You can simply take your WAR file and upload it to Elastic Beanstalk.

The basic logic is to replace your existing class which contains your main method with the SpringBoot version which looks like this:

public class Application extends SpringBootServletInitializer {  
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {  
        return application.sources(Application.class);  
    public static void main(String[] args) throws Exception {  
        SpringApplication.run(Application.class, args);  

[Related Blog: AWS vs Azure]

Step 4: Deploy Your Code 

Your code is prepared for getting ready to deploy to AWS. Make sure you have set up Maven to deploy your project as a WAR file which can be seen inside of your pom.xml file under that looks something like this:

< ?xml version="1.0" encoding="UTF-8"? >  
< project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >  
    < modelVersion >4.0.0< /modelVersion >  
    < groupId >com.proffesso< /groupId >  
    < artifactId >proffesso-core< /artifactId >  
    < version >< /version >  
    < !-- Here's where you set it up as a WAR file-- >  
    < packaging>war< /packaging >  
    < name >CourseCreation< /name >  
    < description >CourseCreation project for Spring Boot< /description >  
< /project >

The next step is to maven package your code together into a deployable WAR file by selecting your application's root project folder and running it as Maven install.

Amazons AWS Cloud

Then, you need to upload and deploy your source code file.

Amazons AWS Cloud

By hitting that deploy button your WAR file gets uploaded to Elastic Beanstalk and deployed in front of you. Once it is reported to OK health status, you should be able to visit your unique URL for your website.

Step 5: Create a Database using Amazon RDS in AWS

By following the steps sincerely, you have successfully launched your application into the cloud but what if you still need to hook it up to a database. The newly launched cloud application does not work properly using a reference to localhost:8080 fro your database connection string. To overcome this, you need to launch a database in the cloud using Amazon RDS.
Amazons AWS CloudIf you have already created an RDS instance before, you just need to click the 'Launch a DB instance' button. We will be creating a MySQL instance which tends to be cheap as MySQL is free. You can also choose whichever option suits your needs.Amazons AWS CloudAmazons AWS CloudNext, we will need to choose what kind of instance to run for the database and specify your DB details for free tier support.

Amazons AWS Cloud

Amazons AWS Cloud

Amazons AWS Cloud

After all these steps, you are all set to launch your first Amazon RDS instance. But still, there require another configuration we need to do. Go ahead and click on 'View Your DB Instance' to watch your database get created before your eyes as it usually takes 10 minutes to get through the entire process.

Amazons AWS Cloud

Step 6: Amazon RDS Instance Configuration

Once the status of your DB instance is set to available, you will be ready to start configuring things. You can connect your DB from outside of your Virtual Private Cloud. Identify which security group was created for your DB instance to expand the details section.
Amazons AWS CloudYou can also head over to the EC2 page by clicking on Services.
Amazons AWS CloudYou can click the Edit button to edit the inbound rules and edit the existing rule or add a new one like so. Also, you can choose a new rule and open it up to allow all inbound traffic as given in the below screenshots.
Amazons AWS CloudAmazons AWS CloudThus, your new DB instance is ready to rock.

Step 7: Connect Code to the RDS Instance

You can log into the DB instance using MySQL Workbench or Toad for MySQL by following the given procedure.

  • Host -> Endpoint 
  • Username -> myUsername
  • Password -> [your password]
  • Database -> myDatabaseName
  • Port -> 3306

Amazons AWS cloudNext, you need to connect your application code to this database via your properties file which you used to connect to your database previously. This can be found in your application.properties file if you are using a Spring Boot application.

Frequently Asked AWS Interview Questions

Step 8: Add a Domain Name to your new Hosted Application

To get rid of the non-friendly UEL that Elastic Beanstalk assigns to your application, you can use another AWS product called 'Route 53'. Once you begin with it, you can create 'Hosted Zones' which allow forwarding our incoming HTTP traffic to our Elastic Beanstalk application from any domain we owe. 

The only pre-requisite is that you will need to own a domain name that will get forwarded to the Elastic Beanstalk application. To point towards the AWS app when someone navigates to your domain name, create a new 'Record Set' and also point to a subdomain to the same place as well. And Voila! you are all set to go.
Amazons AWS CloudBefore you go…

In a few simple clicks and steps, you can deploy a simple yet production-ready Spring Boot application with a MySQL database on AWS using Elastic Beanstalk. The launch and configuration of the environment as a part of Elastic Beanstalk to launch resources using other AWS services as these resources still remain under your control. These resources can be accessed through other AWS service consoles like EC2 and RDS. 

With the help of deploying your Java enterprise application to Amazon's AWS cloud computing helps to trade capital expense for the variable expense, benefits from massive economies of scale, delimits the storage capacity, increases the speed and agility, and also ease out from maintaining data centers as well as gets global in minutes of time. So, what are you waiting for? Start now

Are you interested to learn  AWS and building a career in Cloud Computing?  Then check out our AWS Certification Training Course at your near Cities

AWS Online Training in Ahmedabad, AWS Online Training in BangaloreAWS Online Training in ChennaiAWS Online Training in DelhiAWS Online Training in DallasAWS Online Training in HyderabadAWS Online Training in Kolkata, AWS Online Training in LondonAWS Online Training in MumbaiAWS Online Training in NewYorkAWS Online Training in NoidaAWS Online Training in PuneAWS Online Training in Toronto

These courses are incorporated with Live instructor-led training, Industry Use cases, and hands-on live projects. This training program will make you an expert in AWS and help you to achieve your dream job


Join our newsletter

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
AWS TrainingAug 05 to Aug 20
AWS TrainingAug 08 to Aug 23
AWS TrainingAug 12 to Aug 27
AWS TrainingAug 15 to Aug 30
Last updated: 04 August 2023
About Author
Remy Sharp

Prasanthi is an expert writer in MongoDB, and has written for various reputable online and print publications. At present, she is working for MindMajix, and writes content not only on MongoDB, but also on Sharepoint, Uipath, and AWS.

Recommended Courses

1 /15