2020-03-20

CentOS6.9安装jdk-8u241-linux-x64.rpm

一、查看是否有默认安装的 rpm -qa | grep jdk

二、如有删除 yum remove xxx

三、官网下载链接 https://www.oracle.com/java/technologies/javase-jdk8-downloads.html

三、上传包文件或使用wget下载 wget https://download.oracle.com/otn/java/jdk/8u241-b07/1f5b5a70bf22433b84d0e960903adac8/jdk-8u241-linux-x64.rpm?AuthParam=1584673542_643474cbde921642fcc2b6aadb27c1d0

四、解压 rpm -ivh jdk-8u241-linux-x64.rpm

五、配置环境变量

1、编辑 vim /etc/profile

export JAVA_HOME=/usr/java/jdk1.8.0_241-amd64

export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$JAVA_HOME/bin:$path

2、保存 :wq

3、配置生效 source /etc/profile

4、验证 java -version

注意:命令报错:-bash: ls: command not found

解决方法(临时):

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

path后面追加解决(最终):

export JAVA_HOME=/usr/java/jdk1.8.0_241-amd64

export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export PATH=$JAVA_HOME/bin:$path:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

你可能感兴趣的:(2020-03-20)