1. Prerequisite preparation:
下载JDK:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2. Install JDk:
1. First open the terminal, enter the download directory and unzip it to the current directory: tar -zxvf jdk-8u171-linux-i586.tar.gz #Modify according to the file you downloaded
2. Move the decompressed file to where you want to put it:
sudo mv jdk1.8.0_171 /opt/jdk #here I moved it to /opt/jdk
3. Configure environment variables:
sudo vi ~/.bashrc #The global variables are configured here
Add the following code to the end of the file:
export JAVA_HOME=/opt/jdk/jdk1.8.0_171 # Add the moved JDK path after JAVA_HOME=
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
###/etc/profile ~/.profile /etc/bashrc ~/.bashrc The difference between the four:
/etc/profile is prepared for each user of the system. If you want to set it for each user of the machine, you can set it in /etc/profile uniformly.
~/.profile is the settings file for a single user.
/etc/bashrc is the settings file for all bash shell users
~/.bashrc is the system settings file for a single user.
4. Start the /.bashrc file:
source ~/.bashrc
5. Check the Java version:
java -version
If the Java version number appears, the installation is successful!
###Newbie, please correct me