1. 查看系统安装的版本情况:
rpm -qa | grep jdk
rpm -qa | grep gcj
2. 查看并删除
[[email protected] ~]# rpm -qa|grep jdk java-1.6.0-openjdk-devel-1.6.0.0-1.41.1.10.4.5.alios6.x86_64 java-1.6.0-openjdk-1.6.0.0-1.41.1.10.4.5.alios6.x86_64 [[email protected] ~]# rpm -e --nodeps java-1.6.0-openjdk-devel-1.6.0.0-1.41.1.10.4.5.alios6.x86_64 [[email protected] ~]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.41.1.10.4.5.alios6.x86_64 [[email protected] ~]# rpm -qa|grep gcj libgcj-4.4.6-3.5.alios6.x86_64 [[email protected] ~]# rpm -e --nodeps libgcj-4.4.6-3.5.alios6.x86_64 [[email protected] ~]# java -bash: /usr/bin/java: No such file or directory
3. 安装jdk
3.1 下载jdk
jdk7:http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html
3.2创建安装jdk的目录:
mkdir /usr/local/java
3.3 解压文件到创建的文件夹下:
tar zxvf jdk-7u79-linux-x64.gz -C /usr/local/java
3.4 在profile文件的末尾加入如下命令:
vim /etc/profile
#JAVA_HOME
export JAVA_HOME=/usr/local/jdk1.7.0_79
export PATH=$PATH:$JAVA_HOME/bin
3.5 刷新环境变量
source /etc/profile
3.6 测试java命令是否可用
java -version
完成