Today we are going to install Java 8 (JDK 8, I must say from the developer's perspective) in an Amazon EC2 instance which is having an Amazon Linux version installed in it. In a nutshell we can say that, Amazon Linux can be considered equivalent to CentOS 6.
I am not going to eat your time and jumping directly towards the commands that you have to execute to install JDK 8 on your new instance. Before we start, please ensure you have the administrative privileges. OK.. So, you have to execute the following commands as mentioned below.
Installing Java 8
$ cd /opt
$ sudo wget --no-cookies
--no-check-certificate --header "Cookie:
gpw_e24=http%3A%2F%2Fwww.oracle.com%2F;
oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.tar.gz
$ sudo tar xzf jdk-8u151-linux-x64.tar.gz
$ cd jdk1.8.0_151/
$ sudo alternatives --install
/usr/bin/java java /opt/jdk1.8.0_151/bin/java 2
$ sudo alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1
/usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
2 /opt/jdk1.8.0_151/bin/java
Enter to keep the current selection[+], or type selection
number: 2
(If you are getting some other options as well, choose the one with "/opt/jdk1.8.0_151/bin/java")
$ sudo alternatives --install
/usr/bin/jar jar /opt/jdk1.8.0_151/bin/jar 2
$ sudoalternatives --set jar
/opt/jdk1.8.0_151/bin/jar
$ sudo alternatives --set javac
/opt/jdk1.8.0_151/bin/javac
Check Java version
$ java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed
mode)
Setting environment variables.
# vim /etc/profile
export JAVA_HOME=/opt/jdk1.8.0_151
export JRE_HOME=/opt/jdk1.8.0_151/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
Congratulations!! You did it.. :)
Do share your thoughts if you have any query, suggestion.
Thanks!!

No comments:
Post a Comment