Linux 安装jdk1.8.0_171

将下载的jdk文件解压到 /usr/lib/jvm目录下

sudo nano /etc/profile

修改 /etc目录下的 profile文件,在末尾添加:

set oracle jdk environment

export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_171
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

设置系统默认jdk 版本

sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_171/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_171/bin/javac 300
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.8.0_171/bin/jar 300
sudo update-alternatives --install /usr/bin/javah javah /usr/lib/jvm/jdk1.8.0_171/bin/javah 300
sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk1.8.0_171/bin/javap 300

运行如下命令,切换jdk版本:

sudo update-alternatives --config java

查看jdk版本:

java -version

你可能感兴趣的:(Linux 安装jdk1.8.0_171)