Execute startup jar under linux

Execute the shell script configuration to start jar under linux:

#JVM启动参数
JAVA_OPTS=" -Xms${MIN_MEMORY_SIZE} -Xmx${MAX_MEMORY_SIZE} -XX:PermSize=${MIN_PERM_SIZE} -XX:MaxPermSize=${MAX_PERM_SIZE} "
#用户自定义启动参数
JAVA_PARAM="-Dmyparam=1"
#引用的jar包
LIB="/home/a/lib/*:/home/a/lib2/*"
#指定main对应的类
CLASS_MAIN="com.a.MyMain"
#引用其他sh文件,上面的变量定义都可以放到config.sh中
. ./config.sh
nohup ${JAVA_HOME}/bin/java ${JAVA_OPTS} ${JAVA_PARAM} -classpath ${LIB} ${CLASS_MAIN} > ./nohup.out &


Analysis:

Several ways to execute the main method of the jar package

One, the jar package META-INF/MANIFEST.MF configures the class where the main method is located

java -jar  test.jar   

There are dependent packages:

java -classpath xx.jar -jar test.jar 

java -classpath  /xx/lib/*  -jar test.jar 

Two, the jar package META-INF/MANIFEST.MF does not configure the class where the main method is located

java -classpath  /xx/lib/*   com.xx.MyMain

Guess you like

Origin blog.csdn.net/x18094/article/details/106492923