安装 JDK
官网地址
https://www.oracle.com/java/technologies/javase-jdk13-downloads.html下载安装包
自己想办法下载吧,我是通过 git 传过去的...解压 jdk
tar -xzf jdk-13.0.2_linux-x64_bin.tar_2.gz
-
移动到目录
/usr/lib/jvm/
中sudo mkdir /usr/lib/jvm sudo mv jdk-13.0.2 /usr/lib/jvm/
-
配置环境变量, 编辑文件
/etc/profile
, 在末尾添加
vi /etc/profile
# jdk config export JAVA_HOME=/usr/lib/jvm/jdk-13.0.2 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH={JAVA_HOME}/bin:$PATH
使环境变量生效
source /etc/profile
-
配置jdk
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-13.0.2/bin/java 300 sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-13.0.2/bin/javac 300 sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk-13.0.2/bin/javap 300 sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk-13.0.2/bin/javafoc 300
安装成功
java -version