Tip: Efficient and concise version
Article directory
Preface
As a memo, try to be concise and clear, and start posting the steps directly.
1. Organize the environment
1. First check whether there is Java on the server. If it comes with it, congratulations, you don’t need to install it.
java -version
Generally speaking, if you bring it yourself, the level will be displayed. If you bring it yourself, congratulations, you don’t need to install it. If not, reinstall it.
If the version model and the Java version you want to install are displayed, congratulations. You must uninstall and reinstall. The specific instructions are as follows.
rpm -qa | grep java
1. This command checks related packages
rpm -e --nodeps +包名
2. Delete related packages
rpm -qa | grep java
3. Finally, use the command to check to ensure that the deletion is clean.
2. Deploy jdk1.8
1. Either download it from the official website or any other way, and upload the secure jdk package to the server file through the connection tool; I uploaded it to the jdk folder in the usr directory.
2. Unzip the folder, don’t ask
tar -zxvf 所要解压的文件名
If this instruction is not displayed, please use the command to let the server download the decompression tool. If no error is reported, you can use the connection tool to check whether the usr/jdk directory is decompressed.
3. Establish Java environment
Use the command to edit the profile file: vim /etc/profile;
don’t ask, it’s the same as opening the environment variables when you install the java environment in Windows.
After opening, first enter i
i
Enter the editable state, move to the last blank space, and fill in
JAVA_HOME=/usr/jdk/jdk1.8.0_11
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
Here are some important things to note. Be sure to note that the path to JAVA_HOME must be the path to the decompressed file bin before you double-click it to open it. What does this mean? It means that you click on the decompressed file with the visual connection tool and click to enter until you see the bin file. Once you’ve clipped it, you don’t need to enter it. Copy the path. Remember not to click on bin to copy the path!
After writing, press the esc key and enter the command after typing.
:wq
It means save and exit
4. Validation verification
Finally, let the edited file take effect and execute:
source /etc/profile
Verify after taking effect
java -version
That’s OK! I didn’t try the steps again to see what went wrong. If it doesn’t work, privately chat with the blogger or find other bosses.
Summarize
Finally, I would like to encourage those who view the documentation!