Reprint Address: http://www.cnblogs.com/iwinson/p/6074885.html
1. Operating mechanism of high-level language
We are programmed in high-level languages (except for the writers of Assembler and machine language), computers do not directly understand high-level languages, only understand and run machine language, so the high-level language must be translated into machine language, the computer can run the program written in high-level language.
Translation, in fact, there are two ways to translate, one is to compile, one is to explain. The two ways are only different in the time of translation.
1.1 Compiled languages (e.g. C, C + +, objective-c)
Use a specialized compiler to "translate" a high-level language source code into a machine code (including machine instructions and operands) that can be executed by the platform hardware for a specific platform (operating system), and to package the format of the executable program that the platform recognizes.
Advantages: High Operating efficiency
Cons: compilation-generated programs are not portable
1.2 Interpreted languages (such as Ruby, Python)
A language that uses a dedicated interpreter to interpret the source code on a line-by-row basis into a specific platform's machine codes and execute them immediately. Interpretive languages generally do not compile and link the whole, and interpreted languages are equivalent to mixing compilation and interpretation processes in a compiled language together.
Pros: Easy cross-platform
Cons: Low efficiency, cannot run independently from the interpreter
The operating mechanism of 2.Java language
2.1Java is a combination of compiled and interpreted languages.
① first uses a common Java compiler to compile the Java source program into a platform-independent bytecode file (class file)
The ② is then interpreted by the Java Virtual Machine (JVM) for the bytecode file execution.
Note: Java bytecode is platform agnostic and can run on a variety of different system platforms, but requires different versions of the Java Virtual machine, and the Java runtime of the different system platforms is not the same.
The 2.2 JVM (Java Virtual machine java VM) (1) JVM is the engine of Java bytecode execution that provides the necessary support for the execution of Java programs and optimizes Java bytecode to be converted into more efficient machine instructions. Programs written by programmers are ultimately executed on the JVM, and the load of classes in the JVM is implemented by the class loader (ClassLoader) and its subclasses. (2) ClassLoader is an important system component of the Java runtime that is responsible for locating and loading class files at run time. (3) The JVM masks information related to the operating system platform, enabling Java programs to run on multiple platforms without modification by simply generating bytecode files (class files) that run on the JVM. Different platforms correspond to different JVMs, and when executing bytecode, the JVM is responsible for sending each byte code to be executed to the interpreter, which translates it into machine instructions for a particular platform environment and executes it. The most important feature of the Java language is that it runs across platforms, and the JVM is designed to support operating system-independent, cross-platform operations. 2.3 ClassLoader (1) is part of the JVM implementation, including the Bootstrapclassloader (Startup ClassLoader) (2) ClassLoader loading the Java Core API while the JVM is running, Through the Java program implementation of two Classloader:①extclassloader, its role is to load Java extension API, that is, Lib\ext class; ②appclassloader, Used to load the class in the Classpath settings directory on the user's machine. (3) ClassLoader loading process: When running a program, the JVM starts, runs Bootstrapclassloader, the ClassLoader loads the Java Core API, and then calls EXTC Lassloader load Extension API, finally appclassloader load classpath directory defined CLASS. 2.4JREJRE is Javaruntimeenvironment,java runtime environment, It is the set of environments necessary for Java programs to run, consisting mainly of Java virtual machines, Java platform core classes, and several supporting files. It does not include development tools, compilers, debuggers, and other tools. When executing Java programs, the operating system looks for the JRE environment in the following order. (1) First find out if there is a JRE (2) in the current directory and then find the parent directory with no JRE (3) Then look for the JRE (4) registry in the path developed by the environment variable path view CurreThe Ntversion key value points to which JREJRE comes with the underlying class library primarily in the Jre\lib\rt.jar file. When the program runs, the JRE is responsible for locating and loading the base class library and other class libraries referenced by the ClassLoader (ClassLoader). Base Class Library, ClassLoader automatically to the location of Rt.jar, other class libraries, classloader in the environment variable classpath the path of the search. 2.5 JDKJDK is a Java Development kit, or Java SDK. The JDK is the core of Java. It includes a Java runtime environment, a stack of Java Toolkit Java-based class libraries (Rt.jar). The JDK contains the entire contents of the JRE and includes tools that developers use to compile, debug, and run Java programs. The relationship between the JDK, JRE, and JVM: The JDK, JRE, and JVM are the containment relationships. The range is from large to small, in turn, JDK, JRE, JVM.
Talk about the Java operating mechanism