Oracle JDK is recommended for most of the development, some jars like rt.jar which are required by some java libraries/projects are not available in other options e.g OpenJDK. Here are few simple steps with which you can install and configure Oracle JDK (JDK 1.8)on your EC2 instance.
Download JDK (1.8)from Oracle
wget --no-cookies --header "Cookie: gpw_e24=xxx; oraclelicense=accept-securebackup-cookie;" "http://download.oracle.com/otn-pub/java/jdk/8u11-b12/jdk-8u11-linux-x64.rpm"
Install JDK 1.8
sudo rpm -i jdk-8u11-linux-x64.rpm
Check If It points to new JDK installed
It may still be pointing to previously installed JDK or any other JDK from different distribution, If yes then,
sudo /usr/sbin/alternatives –install /usr/bin/java java /usr/java/jdk1.8.0_11/bin/java 20000
Set newly Installed JDK as your default Java
sudo /usr/sbin/alternatives --config java