CentOS 8.0 configures the environment of openjdk8

One-click installation jdk command

yum install java-1.8.0-openjdk* -y

Execute this command on the server, and the jdk environment is configured

* Indicates that all components of jdk will be downloaded

Because of the language characteristics of java, you can run the project without using the java compilation environment, and you only need to install jre to run the project

In the actual deployment, the server already has an openjdk operating environment, lacks the javac command, the project uses nacos as the registration center, and starts nacos to report an error

 It can be seen from the error message that nacos needs to be compiled first, so we need to install and compile the java editing command, and configure JAVA_HOME. If you are installing all components, you can skip the following steps

The next step is to install the javac command, according to Du Niang:

After installing openjdk, javac, jps and other commands cannot be used. Since the opendjk installed on centos lacks devel components, it needs to be installed by itself.

Find the devel components of openjdk

# yum search openjdk

Download according to the version you installed, mine is version 1.8

# yum install java-1.8.0-openjdk-devel.x86_64

After the download is complete, the environment is configured

First find the installation directory

ls -lrt means to list the files in the current working directory in reverse order of modification time. ls -l means to list the files in the current working directory in order of name, abbreviated as ll.

1. ls means to list the files in the current directory.

  • -l means to enable long list output, which will output detailed information such as file permissions, reference counts, owners, groups, file sizes, modification dates, and file names.
  • -t Sort by time, the newest files will be on top.
  • -r means reverse sort, output in reverse order.
  • -x Output in columns, sorted horizontally.
  • -u Sort files by when they were last accessed.
     

 execute twice

 You can know the installation path

 Configure environment variables

# vim /etc/profile
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el8_1.x86_64
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

Refresh with the command after saving and exiting

# source /etc/profile

Start successfully

Guess you like

Origin blog.csdn.net/m0_46803792/article/details/119037939