1、 Create a new Java folder under the /usr/local directory
mkdir /usr/local/java
Copy jdk to /usr/local/java into the java folder, unzip the compressed package
tar xvf jdk-8u181-linux-x64.tar.gz
2、 Setting environment variables The global setting method is used here, which is to modify etc/profile, which is a common environment variable for all users. Find /etc/profile, edit, and add at the end
export JAVA_HOME=/usr/local/java/jdk1.8.0_181
export JRE_HOME=/usr/local/java/jdk1.8.0_181/jre
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$PATH
In the above adding process, do not add spaces on both sides of the equal sign, otherwise "not a valid identifier" will appear, because extra spaces cannot be recognized when source /etc/profile, and it will be understood as part of the path.
Then save.
Run the following command to make the profile effective.
source /etc/profile
3、 Check whether it is successful in the terminal
java -version
javac
to sum up
The above is the method of installing jdk1.8 on centOS7 that the editor introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message. The editor will reply to you in time. Thank you very much for your support to the ZaLou.Cn website!
Recommended Posts