首先下载JDK安装包:jdk-8u102-linux-x64.tar.gz
创建目录:mkdir -p /usr/local/java
将安装解压到该目录 tar -zxvf jdk-8u102-linux-x64.tar.gz -C/usr/local/java
配置环境变量
vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_102
export JRE_HOME=/usr/local/java/jdk1.8.0_102/jre
export PATH=$PATH:/usr/local/java/jdk1.8.0_102/bin
export CLASSPATH=./:/usr/local/java/jdk1.8.0_102/lib:/usr/local/java/jdk1.8.0_102/jre/lib
退出保存
然后使配置立即生效
source /etc/profile
验证是否配置正确
执行 java
执行 javac
执行 echo $JAVA_HOME
都有信息输出,证明安装成功,去部署java项目吧!