因为我是Ubuntu系统,所以直接加下载到~/Downloads中了,如果你是Windows,那你需要用 xshell 将文件拖到你的Linux服务器上
注:如果不是Ubuntu系统可能没有sudo,只需要切换到root用户,不用加sudo即可
sudo mkdir /usr/local/java
cd ~/Downloads
sudo tar -xzvf jdk-8u121-linux-x64.tar.gz -C /usr/local/java
sudo rm jdk-8u121-linux-x64.tar.gz
sudo vim /etc/profile
JAVA_HOME=/usr/local/java/jdk1.8.0_121 #注意这里换成你的jdk目录
JRE_HOME=${JAVA_HOME}/jre
CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
PATH=${JAVA_HOME}/bin:$PATH
export JAVA_HOME JRE_HOME PATH CLASSPATH
source /etc/profile
echo $PATH
#会显示类似如下内容,可以看到刚刚加入的jdk
/usr/local/java/jdk1.8.0_121/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)
至此Java安装配置完成!
viencoding.com版权所有,允许转载,但转载请注明出处和原文链接: https://viencoding.com/article/7