标签:
[root@localhost bin]# java -version
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.4) (rhel-1.41.1.10.4.el6-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b11, mixed mode)
[root@localhost bin]# rpm -qa | grep jdk
java-1.6.0-openjdk-javadoc-1.6.0.0-1.41.1.10.4.el6.x86_64
java-1.6.0-openjdk-1.6.0.0-1.41.1.10.4.el6.x86_64
java-1.6.0-openjdk-devel-1.6.0.0-1.41.1.10.4.el6.x86_64
[root@localhost bin]# rpm -e --nodeps java-1.6.0-openjdk-javadoc-1.6.0.0-1.41.1.10.4.el6.x86_64
[root@localhost bin]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.41.1.10.4.el6.x86_64
[root@localhost bin]# rpm -e --nodeps java-1.6.0-openjdk-devel-1.6.0.0-1.41.1.10.4.el6.x86_64
[root@localhost bin]# rpm -qa | grep jdk
[root@localhost bin]#
自己去官网下
jdk1.6.0_45-linux-x64.tar.gz
[root@localhost soft]# tar -zxvf jdk1.6.0_45-linux-x64.tar.gz
[root@localhost ~]# mkdir /usr/java
[root@localhost ~]# mv jdk1.6.0_45/ /usr/java/jdk1.6.0_45
配置/etc/profile,在文件末尾加上如下配置:
JAVA_HOME=/usr/java/jdk1.6.0_45
CLASSPATH=.:$JAVA_HOME/lib.tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH
配置普通用户的.bash_profile,示例以crxj-app为例,则可 vi /home/crxj-app/.bash_profile,加上如下配置:
JAVA_HOME=/usr/java/jdk1.6.0_45
JAVA_BIN=/usr/java/jdk1.6.0_45/bin
CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib:$JAVA_HOME/bin
export JAVA_HOME JAVA_BIN CLASSPATH
export PATH=$PATH:$JAVA_HOME/bin
生效配置环境
[crxj-app@CRXJ-APP-2 uap]$ source /etc/profile
测试JDK环境
#下列任意命令都可以检测JDK环境是否安装正确
java -version
javac -version
echo $JAVA_HOME
标签:
原文地址:http://www.cnblogs.com/collin/p/5406528.html