I am a newer in shell script, following is a shell script:
$JAVA_HOME/bin/java -Dpid=MyJava \
-Xms${HEAP_MIN}m -Xmx${HEAP_MAX}m -cp ${CPG_CLASSPATH} \
-Dconfig=${CFG_FILE} \
-Dcom.test.eps.configpath=${my_config}/ \
-Dcom.test.eps.rt.config=${my_config}/ \
-Dlog4j.configuration=file:///${my_config}/log4j.properties.ewf.rt \
com.test.MyJava &
Can anyone tell me the code meaning of every line above?
$JAVA_HOME/bin/java— invokes the JRE binary located at the bin path of the folder designated by the$JAVA_HOMEvariable set in the current user’s enviornment. That is, it runs Java, specifically the version pointed at by JAVA_HOME.The trailing
\s are escape charecters which escape the newline at the end of the line. Normally in a shell program a newline at the end of the line tells the shell that you’re done with the command and it can interpret it now. Ending a line with\tells the shell that the command will actually continue on the next line, i.e. this is all one command.-Dpid=myJava— sets a system property for the jre named pid with value myJava. Java programs can basically ask,getProperty("pid")at runtime and it will return"myJava"and then choose its behavior appropriately, this is a way of configuring the programs the the JRE runs.-Xms${HEAP_MIN}m— sets javas min heap size to value in${HEAP_MIN}env var. The heap size is how much memory the jre sets aside to store its stack trace.-Xmx${HEAP_MAX}m— sets Java’s max heap size to value in${HEAP_MAX}env var.-cp ${CPG_CLASSPATH}— sets the Java classpath to the value in the${CPG_CLASSPATH}env var.-Dconfig=${CFG_FILE}— sets a system property for the JRE named config with value ${CFG_FILE}.-Dcom.test.eps.configpath=${my_config}/— sets a system property for the JRE namedcom.test.eps.configpathwith value${my_config}.-Dcom.test.eps.rt.config=${my_config}/— sets a system property for the JRE namedcom.test.eps.rt.configwith value${my_config}.-Dlog4j.configuration=file:///${my_config}/log4j.properties.ewf.rt— sets a system property for the JRE named log4j.configuration with valuefile:///${my_config}/log4j.properties.ewf.rt.com.test.MyJavais a Java class essentially located on the classpath atcom/test/MyJava.classwhich presumably has amainfunction. After the JRE initializes with all of the previous configurations set, it will run this class and run its main function.&tells the OS to run this command in its own process and not to wait for it to return before the cli gives control back to the user. It’s basically telling the OS to run this program in a process separate from the one which is running your shell.