AWS Builder Center
Building a Java Web Application Environment on Amazon EC2

Building a Java Web Application Environment on Amazon EC2

As a student learning cloud and DevOps, I have been trying to spend more time doing hands-on projects instead of only reading about the concepts. For this project, I set up a Java web application environment on Amazon EC2 using Amazon Linux 2023, SSH, Apache Maven and Amazon Corretto 8. I also connected Visual Studio Code directly to the EC2 instance using Remote-SSH. What started as a guided setup became a useful troubleshooting experience when my EC2 instance ran into a memory issue.

Cloud and DevOps Learner | Powered by Curiosity

Setting Up the Cloud Server

I started by launching an Amazon EC2 instance to serve as the remote Linux server for the project. I created an SSH key pair and used it to connect to the instance securely from my local terminal.
Once connected, I installed Amazon Corretto 8 and Apache Maven. I then used a Maven archetype to generate the basic structure of a Java web application.
Seeing the  BUILD SUCCESS  result was a small but satisfying moment because it confirmed that Java, Maven and the application structure had been set up correctly.

Working with VS Code Remote-SSH

After creating the application, I connected Visual Studio Code directly to the EC2 instance using the Remote-SSH extension.
This allowed me to explore and edit the files stored on the remote server without downloading them to my local computer. I located the  index.jsp  file and updated its content through VS Code.
I also wanted to become more comfortable working from the Linux terminal, so I edited the same file using Nano. When I saved the changes and returned to VS Code, the updated content appeared there immediately.
It helped me understand that VS Code Remote-SSH and Nano were simply two different ways of working with the same file stored on the EC2 instance.

When the Instance Ran Out of Memory

The most useful part of this project happened when something went wrong.
I initially used a  t3.micro  instance with 1 GiB of memory. While working through VS Code Remote-SSH, the instance ran out of available memory. Some processes were terminated by the Linux Out-of-Memory killer, and I could no longer connect properly through Remote-SSH.
I checked the instance status and memory usage to understand what had happened. After identifying the memory limitation, I stopped the instance and changed its type from  t3.micro  to  t3.small , which increased the available memory from 1 GiB to 2 GiB.
Once the instance restarted, I confirmed that all status checks had passed. I was then able to reconnect successfully through both SSH and VS Code Remote-SSH.
This experience helped me see how the size of a cloud instance can directly affect the tools and processes running on it. It also reminded me that troubleshooting is an important part of learning—not just an interruption to the project.

What I Learned

Through this project, I gained practical experience in:
  • Launching and managing an Amazon EC2 instance
  • Connecting securely to a remote Linux server using SSH
  • Installing Java and Apache Maven
  • Generating a basic Maven web application
  • Navigating a project through the Linux command line
  • Using VS Code Remote-SSH
  • Editing files through both VS Code and Nano
  • Checking memory usage and troubleshooting an out-of-memory issue
  • Resizing an EC2 instance based on its resource requirements
I am still at the beginning of my AWS and DevOps journey, but projects like this make the concepts easier to understand. The troubleshooting experience was challenging, but it became the part of the project from which I learned the most.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article