Discussion
In this step-by-step walkthrough, you will install Sun Java JRE 1.6.0_25 onto CentOS 5.5. CentOS comes available with openJDK, an open source Java version. Some applications (such as JIRA) may not be fully compatible with this version and require the standard Sun JRE or JDK to function properly. Sun Java is not available via YUM. Installing Sun Java on CentOS is simple, but there are some wrinkles that, if not properly addressed, will cause some needless troubleshooting. These steps are not fully discussed by the Sun Java installation instructions.
Procedure
Download the Linux binary (not the rpm.bin version).
Create a new directory:
mkdir /opt/java
Copy the binary into this new directory
Change the permissions of the binary:
chmod 755 /opt/java/jre-6u25-linux-i586.bin
Launch the binary:
/opt/java/jre-6u25-linux-i586.bin
NOTE: you will not experience a license prompt while this is executing - this is a variation from the Sun Java instructions for this.
Verify that the java directory was created:
ls -l /opt/java
You should see this:
jre1.6.0_25
Change java directory permissions to allow all user access:
chmod 755 /opt/java
Create a new global environment variable for Java with system-wide access:
gedit /etc/profile.d/java.sh
or use
vi /etc/profile.d/java.sh
Add the following lines to this file:
export JRE_HOME=/opt/java/jre1.6.0_25
export PATH=$PATH:$JRE_HOME/bin
export JAVA_HOME=/opt/java/jre1.6.0_25
export JAVA_PATH=$JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
Save and exit.
Verify that the new file has been created:
ls -l /etc/profile.d
One of the items listed should be the following:
java.sh
Load this new global environment variable:
source /etc/profile.d/java.sh
Verify that the new environment variables are active:
echo $JAVA_HOME
This should return (for this procedure):
/opt/java/jre1.6.0_25
Repeat this process for the other global environment variables you created.
Or check for all Java environment variables:
env or printenv
Configure alternatives:
alternatives --install /usr/bin/java java /opt/java/jre1.6.0_25/bin/java 2
Now select which Java is default:
alternatives --config java
This returns
Selection Command
-----------------------------------------------
+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
2 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
3 /opt/java/jre1.6.0_25/bin/java
Enter to keep the current selection[+], or type selection number:
Select 3, or which ever number is associated with the version just installed.
Verify configuration:
java -version
This will return:
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) Client VM (build 20.0-b11, mixed mode, sharing)
This completes this procedure on Sun Java installation to CentOS 5.5.
References
In this step-by-step walkthrough, you will install Sun Java JRE 1.6.0_25 onto CentOS 5.5. CentOS comes available with openJDK, an open source Java version. Some applications (such as JIRA) may not be fully compatible with this version and require the standard Sun JRE or JDK to function properly. Sun Java is not available via YUM. Installing Sun Java on CentOS is simple, but there are some wrinkles that, if not properly addressed, will cause some needless troubleshooting. These steps are not fully discussed by the Sun Java installation instructions.
Procedure
Download the Linux binary (not the rpm.bin version).
Create a new directory:
mkdir /opt/java
Copy the binary into this new directory
Change the permissions of the binary:
chmod 755 /opt/java/jre-6u25-linux-i586.bin
Launch the binary:
/opt/java/jre-6u25-linux-i586.bin
NOTE: you will not experience a license prompt while this is executing - this is a variation from the Sun Java instructions for this.
Verify that the java directory was created:
ls -l /opt/java
You should see this:
jre1.6.0_25
Change java directory permissions to allow all user access:
chmod 755 /opt/java
Create a new global environment variable for Java with system-wide access:
gedit /etc/profile.d/java.sh
or use
vi /etc/profile.d/java.sh
Add the following lines to this file:
export JRE_HOME=/opt/java/jre1.6.0_25
export PATH=$PATH:$JRE_HOME/bin
export JAVA_HOME=/opt/java/jre1.6.0_25
export JAVA_PATH=$JAVA_HOME
export PATH=$PATH:$JAVA_HOME/bin
Save and exit.
Verify that the new file has been created:
ls -l /etc/profile.d
One of the items listed should be the following:
java.sh
Load this new global environment variable:
source /etc/profile.d/java.sh
Verify that the new environment variables are active:
echo $JAVA_HOME
This should return (for this procedure):
/opt/java/jre1.6.0_25
Repeat this process for the other global environment variables you created.
Or check for all Java environment variables:
env or printenv
Configure alternatives:
alternatives --install /usr/bin/java java /opt/java/jre1.6.0_25/bin/java 2
Now select which Java is default:
alternatives --config java
This returns
Selection Command
-----------------------------------------------
+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
2 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
3 /opt/java/jre1.6.0_25/bin/java
Enter to keep the current selection[+], or type selection number:
Select 3, or which ever number is associated with the version just installed.
Verify configuration:
java -version
This will return:
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) Client VM (build 20.0-b11, mixed mode, sharing)
This completes this procedure on Sun Java installation to CentOS 5.5.
References
- HowTo Install Java on CentOS 4 and CentOS 5, CentOS, 10/10/2010.
- CentOS – Install Java Sun JDK, Eureka.
- Installing Sun's Java on CentOS 5.2, Chris Shuld Blog.
- None
1 comment:
Hurray! First tutorial to work for me. Thanks so much.
Post a Comment