Install JDK and configure JDK environment
1. Prepare in advance.
- Install the virtual machine
- Install the Linux environment on the virtual machine
2. Install JDK
Check whether the version of the Linux system is 32-bit or 64-bit Enter
in the Linux command line: uname -a (here is 64-bit)
Go to the JDK official website to download the 64-bit JDK (the download steps are omitted), and visit the link: http://www.oracle.com/technetwork/java/javase/downloads/index.html
- After the download is complete, use the xftp tool to upload the jdk on the machine to the Linux server. The directory is the /opt directory (the /opt directory is equivalent to the program file directory of the Windows system). After the upload is complete, view the /opt directory as shown below
Delete the JDK that comes with the system, and execute the command rpm -qa | grep java to view the corresponding packages of OpenJDK
Delete these four packages
- Unzip the JDK compressed package and execute the command tar -xzvf jdk-10_linux-x64_bin.tar.gz, the JDK directory will be generated in the current path
Configure the relevant environment variables, switch the directory to the /etc/profile file and
use the vi editor to configure the following content
A, JAVA_HOME=/opt/jdk-10
B, PATH=JA VAHO ME/bin: PATH
C、需要执行/etc/profil相关的配置才能生效,执行命令如下:source /etc/profile D、查看系统是否装上jdk,执行如下命令:java -version,返回如下信息,证明安装成功