Centos7安装jdk
1.第一步
将下载的tar包传到虚拟机
2.卸载openjdk
rpm -e --nodeps java-1.6.0-openjdk-1.6.0.35-1.13.7.1.el6_6.i686
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.79-2.5.5.4.el6.i686
3.解压 将tar包解压到你想放的目录下 -C后面是路径
4. 配置环境变量 通过vi /etc/profile i进入编辑
export JAVA_HOME=/usr/java/jdk1.8.0_231 --这里填写自己的路径与jdk版本
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JRE_HOME=$JAVA_HOME/jre
export PATH=$PATH:$JAVA_HOME/bin
ESC 进入底部 :wq! 强制保存并退出 或者:wq
source /etc/profile 使更改的配置立即生效
-
验证是否安装成功
javac
java -version
-
如果配置不成功 先检查 jdk与虚拟机的位数是不是不匹配
链接: https://editor.csdn.net/md/
: