A precondition
1. Download jdk linux version
(1)首先需要注册Oracle账号
(2)登录
(3)查找jdk-8u161-linux-x64.tar.gz并进行下载
2. jdk uploaded to the Ubuntu server above by xftp
(1)使用xshell在服务器中usr/lib下建立一个jvm文件夹。
(2)通过xftp将上述压缩包上传到此文件夹下
Second, placement
1. First detection installation package jdk
rpm -qa | grep java
2. Uninstall version comes on the linux jdk
apt-get install xxxx 安装
apt-get remove xxxx 卸载但不删除配置
apt-get purge xxxx 卸载并且删除相关配置
Reference:
Linux command (5) Ubuntu apt-get command to install uninstall
3. decompress the downloaded jdk
First into usr / lib folder, and then type the following command
tar zxvf jdk-8u161-linux-x64.tar.gz -C /usr/lib/jvm
4. Configure Environment Variables
(1)找到找到 etc/profile使用vim进行编辑,使用以下命令
vim /etc/profile
Add on top
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_161
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
Then save and exit
5. Use the following commands to validate the configuration
source /etc/profile
Third, verify that you have successfully installed
键入java、javac、java -version进行验证如果都可以就代表jdk已经配置成功