Java 8 application on EC2
Solution 1
check Java current version
java -version
install Java 1.8
sudo yum install java-1.8.0
change the Java version
sudo alternatives --config java
Solution 2
Java 8 may not be available out-of-the-box on the AMI that you are looking for. However, you can always install it once the instance is created.
e.g. Check this post which explains how to install java 8 on Ubuntu
OR check this post which explains how to install Java 8 on RHEL/Fedora/CentOS
.
Solution 3
Installing JDK 8:
Step 1: Check the Java Version
java -version
Step 2: Download RPM package of Oracle JDK (8u121)
wget --no-check-certificate --no-cookies --header "Cookie:oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.rpm
Step 4: Install JDK 8
sudo yum install -y jdk-8u141-linux-x64.rpm
Step 5: Verify oracle JDK version
java -version
Installing JRE 1.8
sudo yum install java-1.8.0
change the Java version
sudo alternatives --config java
Solution 4
- Donwload Linux version of JRE from below link to your windows machine as it has browser. Note that if you are using this EC2 instance as server you just need JRE and not complete JDK. https://www.oracle.com/technetwork/java/javase/downloads/server-jre8-downloads-2133154.html
- Tranfer downloaded .tar.gz file using winscp to your EC2 instance.
- Run "tar zxvf jre-8uversion-linux-i586.tar.gz" on your EC2 instance. For more info https://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jre.html#CFHBHAGI
Solution 5
This question is old but this may help with Java 11. If anybody is interested in installing Java JDK 11, I run
sudo amazon-linux-extras install java-openjdk11
in my EC2 instance with Amazon Linux. I got it from here: https://tecadmin.net/install-java-on-amazon-linux/
Related videos on Youtube
Rune Aamodt
NTNU alumni, siv.ing./MSc computer science. Currently working for a large Oslo-based company, developing software for the banking/finance industry.
Updated on March 27, 2021Comments
-
Rune Aamodt about 3 years
I was wondering if anyone knows if it will be possible for me to install Java 8 on an EC2 instance. My application is packed as a fat jar with embedded jetty, so the Java 8 runtime alone should be sufficient.
I'm not too familiar with Linux, and I saw that they only had Java 7 support on the default AMI. Is there a simple command I can run to update to Java 8?
-
Steve almost 9 yearsI am running a free t2.micro 64-bit EC2 instance. Amazon's AMI linux comes with OpenJDK. The command
java -version
showed AMI had Java 7 out-of-the-box. To upgrade to 8 I did 1) installed OpenJDK 8sudo yum install java-1.8.0-openjdk-devel
2) switched to 8sudo alternatives --config java
. The commandjava -version
then reported openjdk version "1.8.0_45" etc. -
user998303 over 4 yearsThe above didn't work for me, but "sudo yum provides java" gave me a list of available packages, and I was able to install Java 11 with "sudo yum install java-11-amazon-corretto-11.0.5+10-1.amzn2.x86_64"
-
Vipin Jain over 4 yearsevery thing is working only change in step 2 remove break line.
-
Aswin Prasad almost 4 years
sudo yum install java-1.8.0
will only install JRE. You have to install JDK also. stackoverflow.com/questions/26313902/… -
Aman almost 4 years@AswinPrasad no it will install jdk (java development kit)
-
Aswin Prasad almost 4 yearsCheck the link.
-
shivamag00 almost 4 yearsStep 2 is not working.... says unable to resolve b15