Linux下Jdk环境安装配置

时间:2021-04-17 18:14:39

Step1.网上下载jdk

http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz

 

Step2.将下载的安装包解压到/usr/local目录

#tar  -zvxf  jdk-8u181-linux-x64.tar.gz

Step3.配置profile文件,即环境变量

#vim /etc/profile

添加如下内容:JAVA_HOME根据实际目录来
JAVA_HOME=/usr/local/jdk1.8
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH

Step4.使配置文件生效

#source /etc/profile

Step5.测试安装配置是否成功

# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)