1. Installation steps

1. Download the JDK installation package

First, download the JDK from the Oracle website

2. Create a Java installation directory and decompress the installation package. There is no fixed decompression directory, similar to Windows.

 sudo mkdir /opt/java
 sudo tar -zxvf jdk-xxxx.tar.gz /opt/java-xx
Copy the code

3. Configure environment variables

Edit the.bashrc file, which is specific to a particular user. Since Linux is a multi-user, multi-task operating system, we cannot do this if we configure global environment variables, which are usually configured in /etc/profile. Sudo gedit /etc/profile adds the following to the end of the file:

#set Java environment
export JAVA_HOME=/opt/java/jdk-xxx
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

sudo gedit ~/.bashrc
Copy the code

The environment variables are as follows. Do not copy them. You need to change them to the actual installation directory

The configuration of this step is very important, which determines the success or failure of our installation. Finally, don’t forget source to make the environment effective:

source ~/.bashrc
Copy the code

4. Check whether it is successful

Echo $JAVA_HOME = $JAVA_HOME = $JAVA_HOME = $JAVA_HOME = $JAVA_HOME = $JAVA_HOME = $JAVA_HOME = $JAVA_HOME

Second, the summary

Install Java methods there are many, in different circumstances can use different methods to install, this is one of the most official installation method, and the inside of the Windows installation is actually the same, various configurations are about the same, and the installation of Java way cleaner, won’t produce something we don’t know file, facilitate our after removed.