解压
1
2
3
4
5
6$ mv /opt
$ mkdir java
$ cd java
$ mv ~/Downloads/jdk-8u144-linux-x64.tar.gz .
$ tar -zxvf jdk-8u144-linux-x64.tar.gz
$ mv jdk-8u144 jdk1.8设置环境变量
1 | $ sudo vi /etc/profile |
在最后加入如下内容1
2
3
4
5#set java environment
export JAVA_HOME=/opt/java/jdk1.8
export JRE_HOME=/opt/java/jdk1.8/jre
export CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
让修改生效1
$ source /etc/profile
- 验证
1
2
3
4$ java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)