How to Install Java
Overview
This page provides steps to install either the Java runtime environment (JRE)
or the Java software development kit (JDK) in a CentOS Linux server.
Normally, you install one or the other, but not both.
The JDK contains the JRE within it, but also includes development tools,
such as the java byte code compiler and the keytool utility.
Installation of JRE
Download the most recent version of JRE from java.sun.com.
Select the Linux RPM in self-extracting file.
Make the downloaded file executable, and then run it:
chmod +x jre-1_5_0_09-linux-i586-rpm.bin
./jre-1_5_0_09-linux-i586-rpm.bin
Press space bar to view the copyright terms, and at the end, type in yes to agree to the terms.
Scripts stored in
/etc/profile.d are called as a part of initialization when a new shell is created.
We will use this procedure to set two important environmental variables related to java.
Create (or edit)
/etc/profile.d/java.sh with the following contents.
(Correct the pathname to match your version of java.)
export JAVA_HOME=/usr/java/latest
export PATH=${PATH}:${JAVA_HOME}/bin
Make the script executable.
chmod +x /etc/profile.d/java.sh