下载 jdk
安装解压:
sudo tar zxvf ./jdk-8u101-linux-x64.tar.gz -C /usr/lib/jvm
cd /usr/lib/jvm
sudo mv jdk-8u101-linux-x64 jdk1.8
修改环境变量:
gedit ~/.bashrc
末尾添加:
export JAVA_HOME=/usr/lib/jvm/jdk1.8
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
保存后退出,输入一下命令生效:
source ~./bashrc
测试
rancvl@rancvl:~$ java -version
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)