Installation environment: ubuntu19.10
JDK version: JDK8
Host: Windows10
This article applies to all Linux systems to install JDK.
First, you need to obtain the JDK installation package, there are two ways:
Then upload it to the server. If you are using a virtual machine, it is more convenient. If not, please use a tool to transfer. It is recommended to use a remote connection tool, which is Xftp6.
After the installation is complete, as shown in the figure:
Then drag the file to the server. Please pay attention to my path here. I chose the /usr/local/src
directory. The tools we use for development are best placed in this folder without affecting system operation. It's just like the document folder in win, and then we selected the project, then create a new folder, and enter the following commands in turn:
cd /usr/local/src
sudo mkdir java
chmod 777/usr/local/src/java
So we have created a folder and modified its permissions so that anyone can read and write:
Next, drag our tar.gz file to this folder. This will take a while:
Enter the directory:
cd /usr/local/src/java
tar -zxvf jdk-8u221-linux-i586.tar.gz
Take a look after decompression:
Configure environment variables:
sudo vi /etc/profile
Append the following at the end of the file:
# set java environment
export JAVA_HOME=/usr/local/src/java/jdk1.8.0_221 ##Note here that the directory should be replaced with the jdk directory that you decompressed
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
Make the environment variable take effect immediately:
source /etc/profile
Check the java version to see if the installation is successful:
java -version
I encountered a problem, but I already pointed it out at the beginning of the article. It is the problem of the number of computers. Before I installed a 32-bit JDK on a 64-bit computer, the error was as follows:
bash:/usr/local/src/java/jdk1.8.0_221/bin/java:No such file or directory
solution:
sudo apt install lib32z1
Just install 32-bit dependencies.
Recommended Posts