Linux安装jdk

oracle官网下载二进制压缩文件

1.解压

2.编辑/etc/profile,添加以下配置

1
2
3
4
export JAVA_HOME=/opt/src/jdk1.8.0_171
export JRE_HOME=/opt/src/jdk1.8.0_171/jre
export PATH=$PATH:/opt/src/jdk1.8.0_171/bin
export CLASSPATH=./:/opt/src/jdk1.8.0_171/lib:/opt/src/jdk1.8.0_171/jre/lib

3.刷新配置

1
source /etc/profile

4.查看配置是否生效

1
java -version

5.出现以下信息就安装成功了

1
2
3
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)