首先创建jvm的目录
mkdir -p /usr/lib/jvm
cd /usr/lib/jvm
然后下载jvm版本
然后解压
tar xvf jdk.tar.gz
接着运行如下命令来配置 Java
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.8.0/bin/javaws" 1
配置jdk
vi /etc/profile
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH={JAVA_HOME}/bin:$PATH
验证java版本
root@iZ28at6z8suZ:~/nexus-3.0.2-02/bin# 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)