I bought a new Aliyun server today, because centos does not provide update support, so I chose the Ubuntu system for the Linux system, and today I will release a series of tutorials on installing on Ubuntu, starting with the JDK today.
Ubuntu system installation JDK tutorial
1. jdk download
The first step is to download the jdk installation package and download it from the official website Oracle . This tutorial uses jdk-8u371-linux-x64.tar.gz as an example
2. Install the lrzsz command (only for newly installed servers)
Due to the newly purchased server, in the first step, we need to update the linux command.
sudo apt-get update
Then it is to install lrzsz:
sudo apt install lrzsz
3. Upload and decompress jdk
After installing the lrzsz command, we can upload the jdk we just downloaded to our Alibaba Cloud, decompress and deploy it.
First enter rz -E
, and then select the jdk file you just downloaded locally.
sudo tar -zxvf jdk-8u371-linux-x64.tar.gz #解压到 当前 目录下
4. Install jdk
4.1 Get the jdk installation path
cd jdk1.8.0_162 #进入JDK目录,
pwd #查看JDK路径,
It is necessary to write down the path of the JDK to be viewed, which will be used later when configuring the environment.
4.2 Setting environment variables
cd ~
vim ~/.bashrc #输入小写i进入insert模式
Then add the following lines at the end of the file, the path corresponding to JAVA_HOME is the path obtained by the above pwd.
export JAVA_HOME=/root/jdk/jdk1.8.0_371
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
Press the Esc key, enter: wq! to save and exit.
4.3 Configuration takes effect
We enter the following command to make the configuration take effect again.
source ~/.bashrc
4.4 Testing
Finally, we enter java -version
, and the following information is returned, indicating that the installation is successful.