Install the JDK

View the operation digit of the computer: uname -arCopy the code

2017 x86_64 x86_64 x86_64 GNU/Linux

If it shows 64-bit, download the corresponding 64-bit package

You are advised to download the tar.gz package

www.oracle.com/technetwork…

Let’s begin the formal installation of the JDK
1. Upload the JDK installation package to /root

jdk-8u131-linux-x64.tar.gz

2. Check whether JDK has been installed in the system

rpm -qa|grep jdk

RPM -e –nodeps Software name // If yes, run the uninstallation command

3. Decompress the JDK installation package to a specified directory

tar -xvf jdk-8u131-linux-x64.tar.gz -C /usr/local/

4. Go to the decompressed directory

cd /usr/local

5. Change the JDK folder name

The mv jdk1.8.0 _131 JDK

6. Configure environment variables

Modify the environment variable configuration file:

vi /etc/profile

Press I to enter edit mode

Skip to the last line and add the following. Note that the JDK is in the same path as the JDK you installed

#java runtime seting
export JAVA_HOME=/usr/local/jdk
export CLASSPATH=$JAVA_HOME/lib:.
export PATH=$JAVA_HOME/bin:$PATH
Copy the code

Press ESC and enter :wq to save the configuration and exit

Reload the environment configuration

source /etc/profile

8, test whether the JDK installation is ok

java -version

9. Write Hello.java

vi Hello.java

class Hello{
	public static void main(String[] args){
	System.out.println("hello,java"); }}Copy the code

Then ESC :wq exits

Vi /etc/profile I Written

javac Hello.java
Copy the code

Deploy the JAR package

1. Create data, then create the test directory and create related folders and files according to the following structure

The directory structure is:

The main jar package, such as myjar, is placed under app, and the contents of the related restart.sh are as follows:

#! /bin/bash base_home='/data/test' app_name='myjar' pid=`ps -ef|grep ${app_name}|grep -v grep|grep -v restart|awk '{print$2}'` if [ -n "${pid}" ] ; then kill -9 ${pid} sleep 10 fi gclog_file=$base_home/log/gc.log dump_dir=$base_home/heapdump errorlogs_dir=$base_home/log java -Xmx1g -Xms1g -XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:GCLogFileSize=128M -XX:NumberOfGCLogFiles=1 -Xloggc:${gclog_file} -XX:HeapDumpPath=${dump_dir} -jar $base_home/app/${app_name}.jar --spring.config.location=$base_home/config/application.yml >> $base_home/log/${app_name}_$(date +'%Y%m%d').log &Copy the code

The thing to notice here{app_name}.jar this may contain the following error:

Error: Unable to access jarfile /app/myjar.jar
Copy the code

Here you may need to change to an absolute path, as follows:

/datat/test/app/${app_name}.jar
Copy the code

Access the relevant path :(this is modified according to the relevant port of your jar

http://ip:8080/

Path to view logs:

cd /log

Here, a log file with the name and date of the relevant JAR package is displayed below :myjar_20190530.log