How to Install Java JDK11 on AWS EC2?
Last Updated :
23 Jul, 2025
AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual computer on which we can perform all our tasks and we have the authority to configure, launch or even dissipate this virtual computer
In this article, we will learn how to Java JDK11 on AWS EC2.
Prerequisite:
- AWS account.
- EC2 Instance.
- User with privileges to create Instance.
Implementation:
Follow the steps below to install Java JDK11 on AWS EC2:
Step 1: Create an AWS Elastic Cloud Compute Instance.
Step 2: Start the EC2 instance that you have created in Step 1.

Step 3: Connect to your EC2 Instance by clicking on Connect Button.

Step 4: A prompt will pop up after connecting.

Step 5: At first check, if Java JDK is already installed or not.
java --version

Step 6: If Java JDK is not installed on your virtual machine then install the Java JDK using the following commands
sudo apt install openjdk-11-jdk-headless
//if the above code doesn't work try this -->
sudo amazon-linux-extras install java-openjdk11

Step 7: Wait for the process to end.
Step 8: We have successfully installed Java JDK11 on our EC2 instance, to check if JDK11 is installed or not, verify using the following command.
java --version

In this way, we can install Java JDK 11 on our EC2 instance using EC2 Instance Connect.
Let's try to create a Java program and then execute that Java program on our EC2 instance:
Java
//java program to calculate sum of two numbers
import java.io.*;
class GFG {
public static void main(String[] args)
{
int x = 10, y = 20;
int sum = x + y;
System.out.println("Sum is : " + sum);
}
}
Use the following command to compile and execute our java program on AWS EC2 Instance -
To Compile - javac example1.java
To Execute - java GFG
Output
Note: if you also use a free tier account, make sure you delete all the resources you have used before logging out.
Similar Reads
How to Install R on AWS EC2? R is widely used as a different programming language. There are several programming languages are present for different purposes. The C programming language is used to get basic knowledge in the programming field. Java programming language is used to get some deep knowledge of programming & its
7 min read
How to Install Go on AWS EC2? EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual computer on which we can perform all our tasks and we have the authority to configure, launch or even dissipate this virtual computer.Go is an open-source,
2 min read
How to Install MySQL on AWS EC2? AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual com
2 min read
How to Install PHP on AWS EC2? AWS or Amazon web services is a cloud service platform that provides on-demand computational services, databases, storage space, and many more services. EC2 or Elastic Compute Cloud is a scalable computing service launched on the AWS cloud platform. In simpler words, EC2 is nothing but a virtual com
2 min read
How to Install Java JDK9 on Linux? As we all know Java is widely used in tech industries, with around 4 billion devices currently using java. This Java installation is going to be very easy and beginner-friendly. In this article, we are going to see a step-by-step guide on how you can install java on your Linux machine. Step-By-Step
4 min read
How to Install Java on Arch Linux? Java is one of the most popular programming languages. Today, many applications are using Java. Java consists of JRE (Java Runtime Environment) and JDK (Java Development Toolkit). JRE is the  Java Runtime Environment which is provided libraries to run and compile Java programs. JDK provides the comp
3 min read