Table of contents
1. The first step: use the yum command to find the JDK
2. Step 2: Execute the installation command
3. Step 3: Verify whether the installation is successful
4. Step 4: Verify that it is available
5. Step 5: Install the development environment
6. Step 6: Configure environment variables
Today I applied for the company's development machine, and I plan to install some basic environments on the development machine for learning and practice. But what is frustrating is that the machine that is applied for is bare metal, with nothing, just a basic operating system, perfect, just about to reconfigure the environment. As java development, the first step is to configure the Java runtime environment. Make a record of some problems encountered in the process again. Prevent forgetting.
Configure JDK
1. The first step: use the yum command to find the JDK
Use the yum command to find the available JDK versions, and you can see that the supported versions cover JDK1.6 to JDK11. You can choose the version you want to use here.
yum search java | grep jdk
2. Step 2: Execute the installation command
I am using JDK8 here, because the version used by the company is consistent on my side. It will wait a long time here, because the various packages that depend on are being downloaded. You can see that many dependent packages are installed in the figure below.
sudo yum -y install java-1.8.0-openjdk.x86_64
3. Step 3: Verify whether the installation is successful
Use the "Java -version" command to check whether the installation is successful. This does not verify whether it is available, but only verifies the installation status. You can see that the installed version 1.8 was successful.
Java -version
4. Step 4: Verify that it is available
Use the command "javac" to verify that Java is available. An error will be reported here: "-bash: javac: command not found", this is because there is still a lack of installation of the development environment.
5. Step 5: Install the development environment
This error: "-bash: javac: command not found", you need to install the java-1.XX-openjdk-devel package, which provides the jps tool. The same routine is first searched and then installed. After the installation is complete, use the javac command to verify that there is no problem.
Find:
yum list |grep jdk-devel
Install:
sudo yum install java-1.8.0-openjdk-devel.x86_64
6. Step 6: Configure environment variables
Environment variable configuration is essential, the code is as follows "vim .bash_profile", after editing, use the source command to make the configuration take effect.
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.362.b08-1.el7_9.x86_64
export PATH=$PATH:$JAVA_HOME/bin
So far, the bare metal configuration of the Java environment is completed, and I hope it can help everyone.