Register the custom jar package as the linux service and centos7jar on centos 7.
On CentOS7, register the custom jar package as the linux service service1 and run the/etc/rc. d/init. create a shell script file named joyupx: vim joyupx/etc/rc. d/init. d/The Directory generally stores shell script files, but the file name cannot contain the suffix ". sh "; the service name must be/etc/rc. d/init. the name of the associated configuration file under the d/directory is identical; otherwise, such a service cannot be found; 2. Add the following code to the joyupx file :#! /Bin/bash # level # chkconfig: 2345 80 90 # description: joyupx service # process name # processname: joyupx-service # directory of the jar package ROOT_PATH =/usr/local/services/tomcat/apache-tomcat-9.0.0.M9/webapps # JDK root directory JAVA_HOME =/usr/local/services/jdk /jdk1.8.0 _ 91 PATH = $ PATH: $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin # CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar # CLASSES =$ {CLASSPATH}:/usr/work/space1/bin # e Xport JAVA_HOME # export PATH # export CLASSPATH # source function library #. /etc/rc. d/init. d/functionsstart () {echo-n $ "Starting $ prog: "# java-jar/usr/local/services/tomcat/apache-tomcat-9.0.0.M9/webapps/joyupx-service-jar-with-dependencies.jar java-jar $ ROOT_PATH/joyupx-service-jar-with-dependencies.jar # java-jar *. jar & echo "joyupx service" # java-version # echo "CLASSPATH :$ {CLASSPATH}" # ec Ho "PATH: $ {PATH}" # java-classpath $ CLASSES MyFrame #/usr/work/space1/bin/MyFrame start} stop () {echo-n $ "Stopping $ prog:" javac-version # java-jar/usr/local/services/tomcat/apache-tomcat-9.0.0.M9/webapps/joyupx-service-jar-with-dependencies.jar} restart () {echo-n $ "Reloading $ prog:"} case "$1" in start) start; stop) stop; restart) restart; *) echo $ "Usage: $0 {start | stop | restart} "RETVAL = 1 esac Exit $ RETVAL save and exit: ESC: wq! 3. Grant executable permissions to joyupx: chmod a + x joyupx4, start joyupx service: service joyupx start5, and view joyupx processes: ps-aux | grep joyupx