JDK can be downloaded from the official website or can be downloaded from a certain file server.
1. Create a java folder in the usr directory:
mkdir java
2. Enter the java folder you just created and download jdk:
cd /usr/java
For example:
wget http://www.xxxx.com...jdk-8-linux-x64.tar.gz
3. Unzip jdk and see a directory of jdk1.8.0 in the /usr/java directory:
tar -zxvf jdk-8-linux-x64.tar.gz
4. Delete the original compressed package:
rm -rf jdk-8-linux-x64.tar.gz
5. Set the JDK path and set the environment variables:
vi /etc/profile
Click the i key to edit
At the end of the file:
#set java environmentJAVA_HOME=/user/java/jdk1.8.0CLASSPATH=.:$JAVA_HOME/lib/tools.jarPATH=$JAVA_HOME/bin:$PATHexport JAVA_HOME CLASSPATH PATH
Click
ESC key + :wq + Enter key
Exit and save.
Check out the edits just made:
cat /etc/profile
To make JDK available to all users, you can:
vi /etc/profile.d/java.sh
Enter the following in the new java.sh:
#set java environmentJAVA_HOME=/user/java/jdk1.8.0CLASSPATH=.:$JAVA_HOME/lib/tools.jarPATH=$JAVA_HOME/bin:$PATHexport JAVA_HOME CLASSPATH PATH
Save and exit, and assign permissions to java.sh: chmod 755 /etc/profile.d/java.sh
6. Restart the machine or execute commands:
source /etc/profile
7. Check the Java version:
java -version
As shown in the figure, it can be seen that jdk has been installed successfully!
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.