文件下载路径
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
根据实际需要的版本下载,下载的为对应操作系统的压缩源码文件
tar -zxvf jdk-8u181-linux-x64.tar.gz 解压到指定的路径下
设置环境变量:
]#cd /etc/profile.d/
]#vim jdk1.8.0_181.sh
export JAVA_HOME="/usr/local/services/jdk1.8.0_181"
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
对文件添加执行权限
]#chmod +x jdk1.8.0_181.sh
然后source启动
source /etc/profile.d/jdk1.8.0_181.sh
进行测试:
$ java -version java version "1.8.0_181" Java(TM) SE Runtime Environment (build 1.8.0_181-b13) Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode) |