-
首先去官网下载jdk8
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html -
创建一个目录/usr/lib/jvm
sudo mkdir /usr/lib/jvm
-
解压缩安装包至该目录下
sudo tar zxvf jdk-8u121-linux-x64.tar.gz -C /usr/lib/jvm
-
进入到/usr/lib/jvm目录下
cd /usr/lib/jvm
-
把解压后的jdk1.8.0_25重命名为jdk-8
sudo mv jdk1.8.0_121 jdk8
-
添加环境变量
vim ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/jdk8
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
- 测试是否安装成功
java -version
网友评论