1. 下载1.8u121的JAVA JDK
下载地址:http://java.sun.com/javase/downloads/index.jsp
2. 解压缩文件并移动至/lib/jvm
tar -xzvf jdk-8u91-linux-x64.tar.gz
mv jdk1.8.0_191 /lib/jvm
cd /lib/jvm/jdk1.8.0_191
3. 设置环境变量
执行 gedit ~/.bashrc , 并添加下列内容
# install JAVA JDK
export JAVA_HOME=/lib/jvm/jdk1.8.0_191
export CLASSPATH= .:${JAVA_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
保存退出
执行 source ~/.bashrc
4. 安装并注册
执行:
update-alternatives --install /usr/bin/java java /lib/jvm/jdk1.8.0_191/bin/java 1
update-alternatives --install /usr/bin/javac javac /lib/jvm/jdk1.8.0_191/bin/javac 1
update-alternatives --set java /lib/jvm/jdk1.8.0_191/bin/java
update-alternatives --set javac /lib/jvm/jdk1.8.0_191/bin/javac
查看结果:
image
则说明安装成功。
网友评论