Having Redhat or Centos Linux installed and running, by default the Operating system might come with an older Java Version, like 1.4.x
Download just the Java Binary self extractable:
http://www.java.com/en/download/linux_manual.jsp
- Create a new directory in /usr: mkdir /usr/java
- copy jrebinary file file to /usr/java
- Run and complete the java installation: /usr/java/jre-1_5_0_14-linux-i586-rpm.bin
- Create the java environment variables and make sure they are loaded when a session is open. To do that:
- Create a new file java.sh in the profile.d directory: vi /etc/profile.d/java.sh
- Type the following text:
#!/bin/sh
JAVA_HOME=/usr/java/jre1.5.0_15
export JAVA_HOME
JAVA_BIN=$JAVA_HOME/bin
CLASSPATH=$CLASSPATH:$JAVA_HOME:$JAVA_HOME/lib
PATH=$JAVA_BIN:$PATH
export JAVA_BIN CLASSPATH PATH
- Save the file and exit the editor
- Close the session and open it again. To make sure the environment variables are created, type the command: export and make sure that the JAVA_HOME and JAVA_BIN are listed.
- Type the following command to add the installed java version to the RedHat configuration:
/usr/sbin/alternatives –install /usr/bin/java java /usr/java/jre1.5.0_15/bin/java 2
- Type the following command: /usr/sbin/alternatives –config java
- The following text will be displayed:
Selection Command
———————————————–
+ 1 /usr/lib/jvm/jre-1.5.0-gcj/bin/java
2 /usr/java/jre1.5.0_15/bin/java
Enter to keep the current selection[+], or type selection number:
- Type 2 and press Enter.
- To verify that RedHat is now using the correct version of Java, type: java -version and make sure that the JRE 1.5.0.15 is used.