Note
Install the OpenJDK RPM.
From the CLI
yum install
java-1.6.0-openjdk-devel
yum install
java-1.7.0-openjdk-devel
From a GUI
openjdk
and choose the java-1.6.0-openjdk-devel
option
for OpenJDK 6 or the java-1.7.0-openjdk-devel
option for OpenJDK
7.Optional: Set the JAVA_HOME
environment variable.
JAVA_HOME
environment
variable. If you need to do this, follow these steps.JAVA_HOME
. Red Hat Enterprise Linux installs OpenJDK
1.6 into either /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/
or /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/
,
depending on whether your system is a 32-bit or 64-bit architecture.
The JAVA_HOME
should point to the
directory containing a bin/java
executable./home/username
/.bashrc
.export JAVA_HOME="/path/to/java/home
"
Switch between different OpenJDK versions using
the alternatives
utility.
alternatives
, which lets you change
the default version for applications which allow multiple versions to be
installed. OpenJDK is one such application.alternatives
utility, perform the following steps.
Note that setting the environment variables overrides the behavior of
the alternatives
command. For instance,
if you use a script which manually sets $JAVA_HOME
and $JAVA
variables to a different JDK from the one
specified by the alternatives
command,
the environment variables will override the command.root
user, or prefix the commands below with
the sudo
command.alternatives
command is not installed by
default, but may already be installed on your system. If not, install
the alternatives
package by running
the following command:yum install alternatives
/usr/sbin/alternatives --config java
JAVA_HOME
environment variable has been specified as well.
If necessary, the default OpenJDK for your system has been set using
the alternatives
utility.原文:http://www.cnblogs.com/dracula/p/3551545.html