安装jdk的操作
环境:centos6.8
检查centos6.8自带的jdk
#查询版本 [[email protected] package]$ java -version java version "1.7.0_99" OpenJDK Runtime Environment (rhel-2.6.5.1.el6-x86_64 u99-b00) OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode) #查询文件全名 [[email protected] package]$ rpm -qa | grep java tzdata-java-2016c-1.el6.noarch java-1.7.0-openjdk-1.7.0.99-2.6.5.1.el6.x86_64 java-1.6.0-openjdk-1.6.0.38-1.13.10.4.el6.x86_64
卸载自带的jdk(使用root帐号)
[[email protected] package]# rpm -e --nodeps tzdata-java-2016c-1.el6.noarch [[email protected] package]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.99-2.6.5.1.el6.x86_64 [[email protected] package]# rpm -e --nodeps java-1.6.0-openjdk-1.6.0.38-1.13.10.4.el6.x86_64 [[email protected] package]# rpm -qa | grep java [[email protected] package]#
下载jdk,orcale官网下载,使用xftp或者FileZilla传输到虚拟机中(略)
解压缩jdk(root帐号)
##解压缩 [[email protected] app]# tar -zxvf jdk-8u131-linux-x64.tar.gz ##移动到自己的应用路径下 [[email protected] package]# mv jdk1.8.0_131 /home/hadoop/app/
设置环境变量(光标处插入-i,保存退出 ctrl+c,:wq)
[[email protected] jdk1.8.0_131]# pwd /home/hadoop/app/jdk1.8.0_131 [root@sf jdk1.8.0_131]# vim /etc/profile ## /etc/profile里面添加的内容 export JAVA_HOME=/home/hadoop/app/jdk1.8.0_131 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=$JAVA_HOME/lib/:${JRE_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH #光标处插入 i,保存退出 ctrl+c,:wq #执行配置文件使生效 [[email protected] jdk1.8.0_131]# source /etc/profile
检查jdk是否生效
[[email protected] jdk1.8.0_131]# java -version java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode) [root@sf jdk1.8.0_131]#
liunx中jdk安装结束。
原文地址:https://www.cnblogs.com/david227/p/9489412.html
时间: 2024-10-13 17:02:06