jdk安装(rpm安装)
1.rpm下载地址
http://www.oracle.com/technetwork/java/javase/downloads/index.html
通过xftp将文件上传到/home的自己创建的目录下
2、如果有安装openjdk 则卸载
先检查版本
java –version
[root@kuangshen ~]# java -version java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode) # 检查 [root@kuangshen ~]# rpm -qa|grep jdk jdk1.8.0_121-1.8.0_121-fcs.x86_64 # 卸载 -e --nodeps 强制删除 [root@kuangshen ~]# rpm -e --nodeps jdk1.8.0_121-1.8.0_121-fcs.x86_64 [root@kuangshen ~]# java -version -bash: /usr/bin/java: No such file or directory # OK
3、安装JDK
# 安装java rpm [root@kuangshen kuangshen]# rpm -ivh jdk-8u221-linux-x64.rpm
4.安装完成后配置环境变量
点击会话,再开一个窗口查询java
[root@VM-0-16-centos ~]# cd /usr/local [root@VM-0-16-centos local]# ls bin etc games include lib lib64 libexec qcloud sbin share src yd.socket.server [root@VM-0-16-centos local]# cd /usr [root@VM-0-16-centos usr]# ls bin etc games include java lib lib64 libexec local sbin share src tmp [root@VM-0-16-centos usr]# cd java [root@VM-0-16-centos java]# ls default jdk1.8.0_281-amd64 latest [root@VM-0-16-centos java]# cd jdk1.8.0_281-amd64/ [root@VM-0-16-centos jdk1.8.0_281-amd64]# ls bin javafx-src.zip legal man src.zip COPYRIGHT jmc.txt lib README.html THIRDPARTYLICENSEREADME-JAVAFX.txt include jre LICENSE release THIRDPARTYLICENSEREADME.txt [root@VM-0-16-centos jdk1.8.0_281-amd64]#
这里查到java的信息 jdk1.8.0_281-amd64
然后编写配置信息
[root@VM-0-16-centos hxl]# vim /etc/profile
进入后在最后添加
JAVA_HOME=/usr/java/jdk1.8.0_221-amd64 CLASSPATH=%JAVA_HOME%/lib:%JAVA_HOME%/jre/lib PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin export PATH CLASSPATH JAVA_HOME
然后点esc 后:wq保存退出
让新增的环境变量生效!
source /etc/profile
测试 java -version
[root@VM-0-16-centos hxl]# java -version java version "1.8.0_281" Java(TM) SE Runtime Environment (build 1.8.0_281-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.281-b09, mixed mode) [root@VM-0-16-centos hxl]#