01-How To Install Java On Linux
01-How To Install Java On Linux
Install Java JDK (JDK will install the JRE implicitly) – so better install the JDK
If you need to install Oracle java, you can either download the JDK or JRE rpm from the Oracle page and
upload the rpm to the Linux machine
Or you can download the rpm directly using the wget command
cd /opt
sudo wget --no-cookies --no-check-certificate --header "Cookie:
gpw_e24=http://www.oracle.com; oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jre-8u51-linux-x64.tar.gz "
sudo rm /opt/jre-8u25-linux-x64.tar.gz
cd /opt
sudo rm /opt/jdk-8u51-linux-x64.tar.gz
Different installation/versions of java can coexist on the same server – you can see all the different
installation via the below command, also you can select the default version of java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51-1.b16.el7_1.x86_64
/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.85-2.6.1.2.el7_1.x86_64
/usr/lib/jvm/jre-1.6.0-openjdk.x86_64
To edit the environment file use your text editor and edit the following file:
Now that you are in the user profile file, add the following code, along with the Path of your installation
from the previous step, to the bottom. ( Example: JAVA_HOME=”YOUR_PATH”)
export JAVA_HOME="/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.51-1.b16.el7_1.x86_64"
Reload the file so all your changes could take effect with the following command:
source /etc/profile
Verify that your implementations are correct with the following command. Confirm :
echo $JAVA_HOME