We manually execute the Java program is this: 1, in Notepad or UE text Editor, write the source program, 2, using the Javac command to compile the source program into a. class file, the compiled. Class bytecode file contains the following: Constantpool: Symbol table; FieldInfo: member variable information in class, MethodInfo: Method description in class, Attribute: Optional additional node. The FieldInfo node contains the name of the member variable, such as flags such as public,private,static. The Constantvalue property is used to store the static value of the invariant member variable. Deprecated and synthetic are used to flag a member variable that is not recommended or generated by the compiler. 3 with the. class file, we can run the Java program by executing the Java Interpretation command. Now let's talk about what happens when you execute the Java command. First, the JVM loads the. class, which is the class loader that loads the class bytecode. A class loader itself is also a Java class, so,The
class loader itself also needs to be loaded by another class loader, there is a problem like having an egg first, or having a chicken first. But the problem with the class loader in Java is easy to solve.
In a Java Virtual machine (JVM)
embedded in a loader called the Bootstrap class, it is used in a specific
Local code implementation of the operating system, which belongs to the Java Virtual Machine kernel, the bootstrap class does not load with a dedicated class loader. The Bootstrap class is responsible for loading the classes in the Java core package (that is, the classes in the Rt.jar file), class of those classes.
getClassLoaderThe () method returns a value of NULL, which means the Bootstrap class loader.
There are two other class loaders in the Java Core package: Extclassloader and Appclassloader, which are written in the Java language
Java class, where
The Extclassloader class load is responsible for loading the classes stored in the jar package in the <java_home>/jre/lib/ext directory,
Appclassloader is responsible for loading the application's startup execution class, which is the Java virtual machine that uses Appclassloader to load the class when the Java command is used to start executing a class.
When compiling and running a JAVA program, the Extclassloader class loader goes through the jar package in the <java_home>/jre/lib/ext directory to search for the class to be loaded, so if it will include the servlet The API's jar package or the Javamail.jar package is copied to the directory, and when you compile the servlet or JavaMail program, you do not have to add the jar package or the Javamail.jar package file that contains the Servlet API in the CLASSPATH environment variable. Above, is a Java program implementation of the approximate process. http://blog.csdn.net/jjeggplant4000/article/details/2130300
The execution process of a Java program (GO)