-
Java program running mechanism, first of all to have a simple understanding of the JVM, Java program running with the help of the JVM. The JVM is a simulation that can be understood as a physical computer, has its own RAM, registers and other "hardware", the JVM is running after the Java compiler compiled the bytecode file, that is, the *.class file, the running portal is the specified. class file of the main () method.
Take the HelloWorld program as an example to illustrate how the JVM runs a Java program:
-
Package Test;public class HelloWorld {public static void main (string[] args) {System.out.println ("Hello world!");}}Using the Java command under the Jre/bin directory to start a Java virtual machine, Java command parameters can be entered in Java view at the command line, the required parameter format is as follows:
Java options-classpath Run_class args
Options open the JVM parameter configuration, support multiple parameter settings, such as JVM size setting-xmx256m-xms64m,-DFILE.ENCODING=GBK output character set, etc.
Run_class identity Identifies the Java class name that needs to be run, note the need to bring the full package name
Calsspath identifies the path that the JVM looks for when it executes the. calss file
The following bat script:
@echo on
Set Classpath=f:\eclipse_workspace\demo\bin
Set option=-dfile.encoding=gbk-xmx256m-xms64m
Set Run_class=test. Test04
Java%option%-classpath%classpath%%run_class%
Starting JVM,JVM with the option parameter will use ClassLoader to load the Run_class specified under-calsspath and call the main () method
The above is just a simple introduction, one question is whether the-classpath class is the JVM loading or loading the specified run_class
Deploy Java Backend Application