CentOS 6.8 安装JDK1.7

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS 6.8 安装JDK1.7相关的知识,希望对你有一定的参考价值。

CentOS 6.8 安装JDK1.7

检查Linux系统是否已安装jdk

[[email protected] ~]# rpm -qa | grep java

tzdata-java-2016c-1.el6.noarch

java-1.6.0-openjdk-1.6.0.38-1.13.10.4.el6.x86_64

java-1.7.0-openjdk-1.7.0.99-2.6.5.1.el6.x86_64

卸载系统自带的java

[[email protected] ~]# rpm -qa | grep java | xargs rpm -e --nodeps

查看卸载结果

[[email protected] ~]# java -version

bash: /usr/bin/java: No such file or directory

卸载成功

下载jdk

http://www.Oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

jdk-7u79-linux-x64.rpm

jdk-7u79-linux-x64.tar.gz

第一种方法:rpm包安装

rpm包导入用户root目录下

[[email protected] ~]# ls

anaconda-ks.cfg id_dsa.pub install.log install.log.syslog

jdk-7u79-linux-x64.rpm

赋予权限

[[email protected] ~]# chmod 755 jdk-7u79-linux-x64.rpm

安装

[[email protected] ~]# rpm -ivh jdk-7u79-linux-x64.rpm

Preparing... ########################################### [100%]

1:jdk ########################################### [100%]

Unpacking JAR files...

rt.jar...

jsse.jar...

charsets.jar...

tools.jar...

localedata.jar...

jfxrt.jar...

安装完成

第二种方法:二进制包安装

建立JAVA_HOME目录

[[email protected] ~]# mkdir /usr/java

将二进制包放在 /usr/java/ 下并解压

[[email protected] ~]# mv jdk-7u79-linux-x64.tar.gz /usr/java

[[email protected] ~]# cd /usr/java

[[email protected] java]# tar xvf jdk-7u79-linux-x64.tar.gz

查看结果

[[email protected] java]# ls

jdk1.7.0_79 jdk-7u79-linux-x64.tar.gz

为了节省空间,可以将二进制包删去

[[email protected] java]# rm -rf jdk-7u79-linux-x64.tar.gz

配置全局java环境变量

[[email protected] java]# vi /etc/profile

最后面添加

export JAVA_HOME=/usr/java/jdk1.7.0_79

export JRE_HOME=$JAVA_HOME/jre

export PATH=$PATH:$JAVA_HOME/bin

export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

保存退出

使profile配置生效

[[email protected] java]# source /etc/profile

配置用户java环境变量

[[email protected] java]# vi ~/.bashrc

export JAVA_HOME=/usr/java/jdk1.7.0_79

export JRE_HOME=$JAVA_HOME/jre

export PATH=$PATH:$JAVA_HOME/bin

export CLASSPATH=./:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

使bashrc配置生效

[[email protected] java]# source ~/.bashrc

检查一下环境变量

[[email protected] java]# echo $JAVA_HOME

/usr/java/jdk1.7.0_79

[[email protected] java]# echo $CLASSPATH

./:/usr/java/jdk1.7.0_79/lib:/usr/java/jdk1.7.0_79/jre/lib

[[email protected] java]# echo $PATH

/usr/local/cmake-2.8.10.2/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/local/cmake-2.8.10.2/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.7.0_79/bin:/usr/java/jdk1.7.0_79/bin

安装完成

最后检测一下已经安装的jdk

[[email protected] java]# java -version

java version "1.7.0_79"

Java(TM) SE Runtime Environment (build 1.7.0_79-b15)

Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

或者输入 javac

CentOS7.2安装JDK1.7 http://www.linuxidc.com/Linux/2016-11/137398.htm

CentOS 搭建JDK环境 http://www.linuxidc.com/Linux/2015-06/118879.htm

Ubuntu 14.04安装JDK1.8.0_25与配置环境变量 http://www.linuxidc.com/Linux/2015-01/112030.htm

Ubuntu 14.04 LTS安装Oracle JDK 1.8 http://www.linuxidc.com/Linux/2014-11/109216.htm

CentOS6.3安装JDK和环境配置 http://www.linuxidc.com/Linux/2012-09/70780.htm

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-12/138912.htm

以上是关于CentOS 6.8 安装JDK1.7的主要内容,如果未能解决你的问题,请参考以下文章

Linux CentOS 6.6安装JDK1.7

centOS下安装JDK1.7

CentOS下安装JDK1.7

CentOS下安装JDK1.7

Centos7.0挂载优盘安装jdk1.7和tomcat7.0

CentOS下安装JDK1.7