How to install Java in AWS EC2

How to install Java in AWS EC2

October 17, 2020 / Eternal Team

Launch an EC2 Instance

Step 1

Login to AWS console and select Service

launch-an-ec2-instance

Step 2

Click on Launch instance

launch-an-ec2-instance

Step 3

Select the OS/AMI of the server (in our case we have selected Ubuntu)

launch-an-ec2-instance

Step 4

Choose the instance type & click on Next

launch-an-ec2-instance

Step 5

Configure instance details & click on Next

launch-an-ec2-instance

Step 6

Add Storage & click on Next

launch-an-ec2-instance

Step 7

Add tags (In our case, key: Name and value: Java-Program this will help to identify the instance) & click on Next

launch-an-ec2-instance

Step 8

Configure Security Group (Please make sure you have SSH port 22 open in the security group) & click on Next

launch-an-ec2-instance

Step 9

Review instance Launch & click on Launch

launch-an-ec2-instance

Step 10

Select an existing key pair or create a new key pair & Click on launch instance

launch-an-ec2-instance

If you are fairly new to AWS environment, you should know “how to launch an EC2 instance in AWS”.

Login to the server

Step 11

SSH into the server

	$ chmod 400 new_keypair.pem #if you have a new key pair
	$ ssh -i new_keypair.pem ubuntu@public_ip_address

launch-an-ec2-instance

Update and Upgrade the server

Step 12

By update and upgrading the server you will get the latest packages and versions to install in the server.

	$ sudo apt update && sudo apt upgrade -y

launch-an-ec2-instance

Install Java JRE

Step 13

install the default Java Runtime Environment (JRE), which will install the JRE from OpenJDK.

	$ sudo apt install default-jre

launch-an-ec2-instance

Install Java JDK

Step 14

You may need the Java Development Kit (JDK) in addition to the JRE in order to compile and run some specific Java-based software.

	$ sudo apt install default-jdk

launch-an-ec2-instance

Check the Java Version

Step 15

To verify that java has installed completely

	$ java -version

Output

launch-an-ec2-instance

And it’s done. Since Java is already installed, you might want to know about how to install Jenkins in Ubuntu on an AWS server.

AWS-Consulting-Partner

Talk to AWS Certified Consultant

Want to start a project?

It’s simple.

Contact us