🚀 Love this tutorial?
Subscribe to Ram N Java for more easy tech guides!
Installing Java JDK 19 on Amazon EC2 (Linux)
Setting up Java on a cloud server might seem difficult, but this guide makes it easy for beginners. Whether you are using Amazon Linux or any other Linux-based operating system, follow these simple steps to get Java 19 up and running.
Step 1: Connect to Your Server
First, open your Putty software or terminal. Copy the Public IPv4 address of your running Amazon EC2 instance from the AWS console and log in successfully.
Step 2: Check for Existing Java
Run the command java -version. If you see "command not found," it means Java is not installed yet, and we can proceed with a fresh installation.
Step 3: Download and Extract JDK 19
Go to the official Oracle website and copy the link for the Linux .tar.gz file. Use the wget command in your terminal to download it. Once downloaded, extract the file using the tar command.
Step 4: Configure Environment Variables
To make Java work globally, we need to set the paths. Move the extracted folder to /usr/share/. Then, open your profile settings using vim and add these three essential lines:
- JAVA_HOME: The location of your JDK folder.
- PATH: Adding Java to your system path.
- CLASSPATH: Necessary for Java to find your libraries.
Step 5: Verify and Run a Program
After saving your changes, re-login to your terminal. Run java -version again, and you should see Java 19 successfully installed! To test it, you can create a simple "Hello World" program, compile it with javac, and run it with the java command.
No comments:
Post a Comment