Java project online cloud server environment (1) - JDK installation and configuration

Java project online cloud server environment (1) - JDK installation and configuration

Server selection:

Alibaba Cloud and Tencent Cloud servers are available. Usually we choose centOS servers. After we purchase the server, if the server does not select an environment configuration, or the environment configuration is different from the local configuration environment of the current project, then we need Configure the server environment. In terms of cloud server jdk, try to choose the jdk version that is consistent with your local project.
Note : After the JDK is downloaded, the Window system can use Xftp to upload the downloaded jdk installation package to a specified folder, such as the /usr/java directory. For macOS systems, you can use Transmit to upload the JDK installation package, for example, in the /usr/java directory.

If there is a way to upload files from the local to the server without the help of Xftp or Transmit, use the following command to upload the local folder to the directory specified by the cloud server:

scp 本地文件绝对路径 [email protected]服务器IP地址:需要传入到服务的哪个文件下的绝对路径

The specific configuration steps of cloud server jdk are as follows:

1. jdk8 download address:

https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html

2. Unzip the compressed package:

tar -xvf jdk-8u162-linux-x64.tar.gz

3. Create a new folder on the cloud server to store the decompressed jdk:

mkdir /usr/java

4. Move the decompressed file to the file where jdk is stored:

mv jdk1.8.0_162 /usr/java

5. Enter editing mode:

vim /etc/profile

6. Add the following content at the end of the file: Note that the file path and jdk version number are changed to your own

export JAVA_HOME=/usr/java/jdk1.8.0_162
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}

7. Make the modified environment variables take effect:

source /etc/profile

8. The following methods can be used to test whether the installation is successful:
1. Execute javac, and the command not found error will not appear.
2. Execute java -version, and the version will be java version "1.8.0_162".
3. Execute echo $PATH, and check whether the environment variables you set are configured. correct

After the test is successful, the server's JDK is configured.

Guess you like

Origin blog.csdn.net/Turniper/article/details/130306387