linux中安装配置jdk1.8

时间:2022-02-12 00:11:29

1.下载jdk-8u11-linux-x64.rpm

2.长传到linux中,在相应目录下运行chmod 777 jdk-8u11-linux-x64.rpm

3.运行rpm -ivh jdk-8u20-linux-x64.rpm安装(默认安装目录在/usr/java下)

3. 运行vim /etc/profile,在文件末尾输入以下几行:

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

4. :wq 保存,退出;

4. 运行source /etc/profile,使/etc/profile文件生效,或者重启;

5. 运行java -version,返回结果如下:

java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

说明JDK1.8已经安装成功!