1. First download the jdk installation package on the official website
What I downloaded is: jdk-7u55-linux-x64.tar.gz
It is best to put the decompressed package under Downloads in the main folder for easy operation.
2. Unzip the compressed package
Enter the command: tar -zxf jdk-7u55-linux-x64.tar.gz and extract it to the current directory.
At this time, the folder jdk1.7.0_55 will be extracted.
Move the folder jdk1.7.0_55 to the specified directory first:
sudo mv Downloads/jdk1.7.0_55 /usr/lib/jvm/
3, set the environment variable and other values
Enter the command in the terminal: gedit ~/.bashrc The text editing interface will appear
Paste the configuration at the end of the document:
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_55
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
Of course don't forget to save.
4, check whether the setting and installation are successful
You can enter the env command to see if the setup is successful.
You can enter: java-version command to view the jdk version
In this way, the jdk environment is successfully configured.