标签:centos6安装jdk
CentOS 6.8 安装JDK1.7检查Linux系统是否已安装jdk
[root@linux1 ~]# 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
[root@linux3 ~]# rpm -qa | grep java | xargs rpm -e --nodeps
查看卸载结果
[root@linux3 ~]# 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目录下
[root@linux2 ~]# ls
anaconda-ks.cfg id_dsa.pub install.log install.log.syslog
jdk-7u79-linux-x64.rpm
赋予权限
[root@linux2 ~]# chmod 755 jdk-7u79-linux-x64.rpm
安装
[root@linux2 ~]# 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目录
[root@linux3 ~]# mkdir /usr/java
将二进制包放在 /usr/java/ 下并解压
[root@linux3 ~]# mv jdk-7u79-linux-x64.tar.gz /usr/java
[root@linux3 ~]# cd /usr/java
[root@linux3 java]# tar xvf jdk-7u79-linux-x64.tar.gz
查看结果
[root@linux3 java]# ls
jdk1.7.0_79 jdk-7u79-linux-x64.tar.gz
为了节省空间,可以将二进制包删去
[root@linux3 java]# rm -rf jdk-7u79-linux-x64.tar.gz
配置全局java环境变量
[root@linux3 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配置生效
[root@linux3 java]# source /etc/profile
配置用户java环境变量
[root@linux3 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配置生效
[root@linux3 java]# source ~/.bashrc
检查一下环境变量
[root@linux3 java]# echo $JAVA_HOME
/usr/java/jdk1.7.0_79
[root@linux3 java]# echo $CLASSPATH
./:/usr/java/jdk1.7.0_79/lib:/usr/java/jdk1.7.0_79/jre/lib
[root@linux3 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
[root@linux3 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
标签:centos6安装jdk
原文地址:http://blog.51cto.com/jack88/2096384