下载地址:http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html
[root@sea sea]# sudo rpm -ivh /目录/jdk-7-linux-x64.rpm
执行结果: Preparing... ################################### [100%] 1:jdk ##################################### [100%] Unpacking JAR files... rt.jar... jsse.jar... charsets.jar... tools.jar... localedata.jar...
2. 设置环境变量 这里我们需要找到profile文件,添加环境变量: #vim /etc/profile 在profile文件下面追加写入下面信息: export JAVA_HOME=/usr/java/jdk1.7.0 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin 保存退出,执行: #source /etc/profile
3. 更新 alternatives,选择JDK版本 首先安装 java alternative ---jdk # update-alternatives --install /usr/bin/java java /usr/java/jdk1.7.0/bin/java 60 然后配置JDK: # update-alternatives --config java
这样就会出现下面的提示: *+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java 2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java 3 /usr/java/jdk1.7.0/bin/java
选择/usr/java/jdk1.7.0/bin/java
# java -version java version "1.7.0" Java(TM) SE Runtime Environment (build 1.7.0-b147) Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing) (责任编辑:IT) |