卸载之前的 jdk
[root@localhost ~]# rpm -qa|grep java
java-1.7.0-openjdk-headless-1.7.0.51-2.4.5.5.el7.x86_64
python-javapackages-3.4.1-5.el7.noarch
tzdata-java-2014b-1.el7.noarch
javapackages-tools-3.4.1-5.el7.noarch
java-1.7.0-openjdk-1.7.0.51-2.4.5.5.el7.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.51-2.4.5.5.el7.x86_64
[root@localhost ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.51-2.4.5.5.el7.x86_64
测试环境 red Hat Linux 5.4
jdk版本 1.7/1.8
jdk下载地址:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
使用xftp工具将安装包传送到linux中
[root@linuxmain ~]# ls anaconda-ks.cfg Desktop install.log install.log.syslog [root@linuxmain ~]# cd /
[root@linuxmain /]# ls bin dev home lost+found misc net proc sbin srv tmp var boot etc lib media mnt opt root selinux sys usr
[root@linuxmain /]# cd usr
[root@linuxmain usr]# ls bin hadoop-2.5.1 java kerberos local src etc hadoop-2.5.1.tar.gz jdk-7u71-linux-i586.rpm lib sbin tmp games include jdk-8u25-linux-i586.rpm libexec share X11R6
[root@linuxmain usr]# rpm -ivh jdk-8u25-linux-i586.rpm
开始安装 ... ...你将会看到如下的代码界面
[root@linuxmain usr]# rpm -ivh jdk-7u71-linux-i586.rpm Preparing... ########################################### [100%] 1:jdk ########################################### [100%] Unpacking JAR files... rt.jar... jsse.jar... charsets.jar... tools.jar... localedata.jar... jfxrt.jar... plugin.jar... javaws.jar.
接下来配置环境变量其实环境变量不配置都可以用的但是还是配置上吧
[root@linuxmain ~]# vi .bashrc
# .bashrc
# User specific aliases and functions
alias rm='rm -i' alias cp='cp -i' alias mv='mv -i'
# Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi
export JAVA_HOME=/usr/java/jdk1.7.0_71
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH ~ ~ ~ ~ ~ ~ ".bashrc" 16L, 335C
输入字母i小写的进入编辑状态 完成之后 输入shift+: 输入wq! 保存退出
[root@linuxmain ~]# java -version java version "1.7.0_71" Java(TM) SE Runtime Environment (build 1.7.0_71-b14) Java HotSpot(TM) Client VM (build 24.71-b01, mixed mode, sharing)
[root@linuxmain ~]#
代表你成功了可以简单的写个测试类测试一下