Linux 安装jdk1.8 设置环境变量

时间:2022-02-22 18:19:25

官网下载jdk下载jdk-8u91-linux-x64.rpm (提取码:3856)

1,安装jdk

[root@localhost java]# rpm -ivh jdk-8u91-linux-x64.rpm 
Preparing...                ########################################### [100%]
   1:jdk1.8.0_91            ########################################### [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
jfxrt.jar...
[root@localhost java]#

2,设置环境变量:

[root@localhost Desktop]# cd /etc/

[root@localhost etc]# vi profile

最底下输入以下内容:

export JAVA_HOME=/usr/java/jdk1.8.0_91
export JAVA_BIN=/usr/java/jdk1.8.0_91/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH